Stream
allows you to separate the "when" from the "what", which isn't possible with IO
zip
them with my logic stream
SignallingRef[IO,Int]
, which is the number of outstanding jobs. On job completion, I execute .update(_ - 1)
. I want to push this new value to the user, which is easy by map
ping the counter.discrete
value. However, updates can come in quick succession, so after sending one update I want to not send the next update sooner than in one second, so possibilities are:Stream[IO,Message]
. I want to make this into a Stream[IO,Option[Message]]
with the following semantics: if there is a was no Message
coming from the original stream within the last 10 seconds, emit a None
. (My usecase: inject keepalives into a stream of websocket messages to the client, but instead of at some fixed interval do it only if I haven't sent any legitimate message within the last 10 seconds)
groupWithin
to take some inspiration
groupWithin
(with a different strategy)
groupWithin
you can see how it's done
Alarm
for every read/write? In any case, in the websocket stream case the exact timeout is not so important so you can merge with a 1 second interval stream and then count upwards, emitting a keepalive on 10, or resetting on a message
Queue
and Ref[F, Token]
List[IO[PdfDocument]]
. Using parSequence
I efficiently get the resulting IO[List[PdfDocument]]
. However, afterwards I want to merge these into 1 document, in the same order. Using parSequence
I can not start merging until all 100 documents are done. So I would need something like a stream of generated documents, that are generated in parallel (like parJoin(n)
), but whose output is still in the original order. So, if document "2" takes very long generate, it will have emitted "1", internally generated already "3", "4" and "5", but only when "2" is ready are these emitted.