immutant

http://immutant.org Note: dev discussion happens in #immutant on FreeNode IRC.
richiardiandrea 2016-07-14T04:09:38.000337Z

Sorry for the newbie question, but i got an UndertowInputStream as body and I was wondering if there is some utils that handles the draining...if not I can go through the classic Java loop with a buffer no problem ;)

2016-07-14T11:39:33.000340Z

@richiardiandrea: is the body text and not too large? if so, you can (slurp the-body)

richiardiandrea 2016-07-14T14:33:57.000343Z

Yeah I guess I can, I was just wondering how to handle partial transmissions @tcrawley

2016-07-14T14:34:35.000344Z

I would assume slurp would block until it could read everything from the stream

richiardiandrea 2016-07-14T14:37:24.000345Z

Uhm right, that is why I need a better way, maybe with a timeout...but thanks I'll try to figure something out :)

richiardiandrea 2016-07-14T14:38:52.000346Z

There is also the interesting ztellman/byte-streams to explore

richiardiandrea 2016-07-14T16:30:39.000347Z

I see that there is a StreamSourceChannel in here https://github.com/undertow-io/undertow/blob/master/core/src/main/java/io/undertow/io/UndertowInputStream.java#L45

richiardiandrea 2016-07-14T16:30:46.000349Z

so maybe I can get it somehow

richiardiandrea 2016-07-14T16:31:32.000350Z

I would like to get something that I can convert to core.async/manifold

richiardiandrea 2016-07-14T16:35:49.000353Z

oh -> http://immutant.org/documentation/2.1.5/apidoc/immutant.web.async.html

2016-07-14T17:27:31.000355Z

@richiardiandrea: yeah, so, if you want to do async stuff in immutant, that's the place to look :)

richiardiandrea 2016-07-14T17:29:09.000356Z

yes but from what I see this channel is for the response...I am digging 😄

2016-07-14T17:29:54.000357Z

can you state what you are trying to to? what's your use case?

richiardiandrea 2016-07-14T17:30:32.000358Z

I would like to parse the InputStream in a non-blocking way

2016-07-14T17:31:06.000359Z

do you want to parse the stream after sending the reply?

2016-07-14T17:31:37.000360Z

if not, you're blocking a thread anyway, unless you use something like spiral, possibly

2016-07-14T17:31:53.000361Z

https://github.com/dgrnbrg/spiral

richiardiandrea 2016-07-14T17:31:55.000363Z

and would like to say, timeout, if the InputStream is stale...

richiardiandrea 2016-07-14T17:31:59.000364Z

oh

2016-07-14T17:32:50.000365Z

I would think that undertow would time out connections for you, closing the InputStream, which will unblock whatever was waiting on it

richiardiandrea 2016-07-14T17:34:07.000366Z

spiral looks like my solution

polymeris 2016-07-14T20:15:03.000368Z

Hi

polymeris 2016-07-14T20:15:21.000369Z

Regarding immutant.scheduling, the docs say ":num-threads Specifies the number of worker threads for the scheduler’s thread pool"

polymeris 2016-07-14T20:15:32.000370Z

is that for all scheduled jobs or just the one?

polymeris 2016-07-14T20:15:56.000371Z

If the later, can I have several jobs share one thread pool?

2016-07-14T20:19:38.000372Z

@polymeris: the thread pool runs all the jobs you schedule through the scheduler instance

2016-07-14T20:24:09.000373Z

if you override the default :num-threads, you should pass it to every schedule call you want to use that pool

2016-07-14T20:24:43.000374Z

you can verify that it's scheduled on the right scheduler by looking at the return value. iirc, the scheduler instance is in that map

2016-07-14T20:25:29.000375Z

effectively, each scheduler (and its associated thread pool) is identified by the value of :num-threads you pass

2016-07-14T20:25:47.000376Z

which i concede is a little weird

polymeris 2016-07-14T20:25:52.000377Z

not sure how to select a scheduler instance. If I just do (schedule fn :every [5 :minutes] :num-threads 5) a few times, do I get the same (default) scheduler instance each time?

2016-07-14T20:26:12.000378Z

yes

polymeris 2016-07-14T20:26:34.000379Z

so I only get another scheduler instance if I select a different :num-threads value?

2016-07-14T20:26:39.000380Z

but if you pass :num-threads 3, that's going to give you a different one

2016-07-14T20:26:41.000381Z

correct

polymeris 2016-07-14T20:26:47.000382Z

oh... I see

polymeris 2016-07-14T20:26:49.000383Z

thanks

2016-07-14T20:26:52.000384Z

np

2016-07-14T20:27:23.000385Z

@polymeris: should be easy to verify at a repl. you should see that scheduler in the result.

polymeris 2016-07-14T20:28:33.000386Z

yeah... i'll experiment a bit

2016-07-14T20:29:02.000387Z

it might be keyed by :id or :ids

polymeris 2016-07-14T20:30:43.000388Z

yeah... i get the same

:ids {#object[org.projectodd.wunderboss.scheduling.QuartzScheduling
               0x4b54118e
               "org.projectodd.wunderboss.scheduling.QuartzScheduling@4b54118e"] ("42356efd-a72e-421b-9ece-421c5939f99f")}

polymeris 2016-07-14T20:31:33.000390Z

the key of that map is the same, but not the value

2016-07-14T20:31:55.000391Z

yeah, i believe that map will grow only if you pass a different :num-threads

2016-07-14T20:32:33.000392Z

subsequent calls with the same :num-threads should grow the value only

polymeris 2016-07-14T20:33:59.000393Z

can you have more than one scheduler with same pool size? not that I need it at the moment, but wondering

2016-07-14T20:35:26.000394Z

not via the immutant api, but you could with java interop to quartz itself