He-Pin opened a new pull request, #3127:
URL: https://github.com/apache/pekko/pull/3127

   ### Motivation
   
   `alsoTo` uses `Broadcast[Out](2, eagerCancel = true)` internally. When the 
side sink fails or cancels, the entire stream is terminated. Users cannot 
isolate the side sink — for example, a fire-and-forget logging sink should not 
kill the main business stream when the logging destination is temporarily 
unavailable.
   
   Fixes #3104.
   
   ### Modification
   
   Add a new `alsoTo(sink, propagateCancellation: Boolean)` overload to both 
Scala and Java DSLs:
   
   - When `propagateCancellation = true` (default), behavior is identical to 
existing `alsoTo`
   - When `propagateCancellation = false`, a new `ResilientAlsoTo` GraphStage 
is used that:
     - Backpressures when either output backpressures (same contract as 
`alsoTo`/`Broadcast`)
     - When the side sink cancels or fails, logs a warning and continues 
forwarding to main downstream only
     - When the main downstream cancels, cancels the side sink normally
   
   Changes:
   - New `ResilientAlsoTo` GraphStage in `Graph.scala`
   - `alsoTo(Graph, Boolean)` and `alsoToMat(Graph, Boolean)(matF)` overloads 
in `FlowOps`/`FlowOpsMat`
   - Java DSL overloads: `Flow`, `Source`, `SubFlow`, `SubSource`
   - Java DSL `alsoToMat(Graph, Boolean, Function2)` overloads: `Flow`, `Source`
   - `FlowWithContext`/`SourceWithContext` overrides
   - `DefaultAttributes.resilientAlsoTo` for stage naming
   
   ### Result
   
   Users can now use `alsoTo(sink, propagateCancellation = false)` to 
fire-and-forget to a side sink without risking main stream termination. Default 
behavior is unchanged and fully backwards-compatible.
   
   ### Tests
   
   - `FlowAlsoToSpec`: 11/11 passed — covers both propagation modes, upstream 
failure, backpressure, side cancellation scenarios
   - `DslConsistencySpec`: 12/12 passed — Scala/Java DSL consistency verified
   - `FlowAlsoToAllSpec`: 2/2 passed — no regression
   
   ```
   sbt "stream-tests / Test / testOnly 
org.apache.pekko.stream.scaladsl.FlowAlsoToSpec"
   ```
   
   ### References
   
   Fixes #3104


-- 
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