He-Pin opened a new issue, #3102:
URL: https://github.com/apache/pekko/issues/3102

   ### Motivation
   
   `GroupBy` requires a fixed `maxSubstreams` limit. When the number of 
distinct keys exceeds this limit, the stream fails with 
`TooManySubstreamsOpenException`. Some use cases (e.g., event routing by 
tenant/user ID) need to handle an unbounded number of keys without a predefined 
limit.
   
   ### Current behavior
   
   `StreamOfStreams.scala:485`:
   ```scala
   } else if (activeSubstreamsMap.size + closedSubstreams.size == 
maxSubstreams) {
     throw tooManySubstreamsOpenException
   }
   ```
   
   Passing `maxSubstreams = -1` technically bypasses the check (sizes can never 
equal -1), but this is undocumented and not an official API contract.
   
   ### Proposed fix
   
   1. Add explicit guard: `if (maxSubstreams >= 0 && activeSubstreamsMap.size + 
closedSubstreams.size == maxSubstreams)`
   2. Update Scaladoc in `Flow.scala:groupBy` to document `-1` as "unlimited 
substreams"
   3. Add `require(maxSubstreams >= -1, ...)` validation
   4. Add tests for `maxSubstreams = -1` with many distinct keys
   5. Document the memory implication: with `allowClosedSubstreamRecreation = 
false`, `closedSubstreams` grows unbounded. Recommend using 
`allowClosedSubstreamRecreation = true` with infinite substreams.
   
   ### References
   
   - Inspired by Akka.NET 
[#7607](https://github.com/akkadotnet/akka.net/pull/7607)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to