You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote a custom graph stage for integrating an actor to a flow in akka streams. One of the reasons for this was that I needed the actor to be notified when the stream completes or fails. I didn't find an easy way to do this with the mapAsync + ask pattern or Flow.ask.
The idea is that the stage will forward all elements of the stream to the configured actorRef, and waits for an acknowledgement of the actor before doing the next pull. The actor can emit elements to the stream by sending an StreamElementOut message back to the stageActor. When the stream fails or completes, a message is send to the actor. When the actor dies, the stage will fail as well.
Another advantage is that it does't have the restriction to be a LinearGraphStage, the actor can emit multiple elements to the stream in response to a single stream element.
I think the specific functionality to notify the actor that is used with Flow.ask when the stream completes or fails, would be a nice addition. In that case I can get rid of the custom code, and use Flow.ask instead. Would that be a valuable contribution?
For the case that the actor is more 'detached' and doesn't necessarily reply to each ask with an out element, there is still no built-in functionality to use. But for the project I am working on now I actually don't need that per se.
I wrote a custom graph stage for integrating an actor to a flow in akka streams. One of the reasons for this was that I needed the actor to be notified when the stream completes or fails. I didn't find an easy way to do this with the mapAsync + ask pattern or Flow.ask.
The idea is that the stage will forward all elements of the stream to the configured actorRef, and waits for an acknowledgement of the actor before doing the next pull. The actor can emit elements to the stream by sending an StreamElementOut message back to the stageActor. When the stream fails or completes, a message is send to the actor. When the actor dies, the stage will fail as well.
Another advantage is that it does't have the restriction to be a LinearGraphStage, the actor can emit multiple elements to the stream in response to a single stream element.
Check here for example code.
If there is any interest, would love to make a PR.
The text was updated successfully, but these errors were encountered: