Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Akka Streams `groupBy` capacity change on SubFlow completion?

When using groupBy in a stream flow definition with some max capacity of n:

source.groupBy(Int.MaxValue, _.key).to(Sink.actorRef)

If I hook up the subflows that result to say, an Actor sink, and purposefully cause the subflows to terminate on some message, will that free up the groupBy capacity? Will it go from n to n-1 back to n if a subflow is ended by the sink? Is this a viable way to set up a dynamic-ish graph?

like image 561
simonl Avatar asked Nov 07 '22 22:11

simonl


1 Answers

Regarding how groupBy works in general: yes, the maxSubstreams capacity is dynamic, i.e. it represents the maximum number of active substreams.

The GroupBy stage keeps a reference of each subflow in its internal state, and this is removed whenever that specific subflow completes.

With regards to your specific example, I don't think there is a way to make sure that "a subflow is ended by the sink". This is because by using to(Sink.actorRef) after a groupBy all the flows are going to feed one single actor.

like image 62
Stefano Bonetti Avatar answered Dec 09 '22 18:12

Stefano Bonetti