apache / pekko

Build highly concurrent, distributed, and resilient message-driven applications using Java/Scala
https://pekko.apache.org/
Apache License 2.0
1.17k stars 140 forks source link

Add alsoTo/alsoToContext to FlowWithContext/SourceWithContext #1443

Closed mdedetrich closed 3 weeks ago

mdedetrich commented 3 weeks ago

This PR adds alsoTo/alsoToContext onto FlowWithContext/SourceWithContext which just wrap the underlying delegate methods, this is analogous to the current map/mapContext methods that already exist.

Note that delegate.alsoTo(Flow.fromFunction { in: (Out, Ctx) => in._2 }.toMat(that)(Keep.right)) is copied from the implementation of contramap. I would have ideally liked to use contramap however the method is not available on a Graph[SinkShape[_]]

I didn't add tests due to the sheer triviality of the implementation but can add them if asked.

mdedetrich commented 3 weeks ago

PR is now ready to review, the link-validator failure is not related

pjfanning commented 3 weeks ago

I would like a couple of trivial test cases - even if for regression purposes. Also useful as a way of documenting the usage.

mdedetrich commented 3 weeks ago

Thanks for the review, everything is passing and I have added the @since, merging.