Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any interest in integrating actor into a Flow though a GraphStage? #140

Open
fmeeuw opened this issue Sep 2, 2018 · 3 comments
Open

Any interest in integrating actor into a Flow though a GraphStage? #140

fmeeuw opened this issue Sep 2, 2018 · 3 comments

Comments

@fmeeuw
Copy link

fmeeuw commented Sep 2, 2018

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.

@johanandren
Copy link
Member

I wonder if it maybe fits together with ask in ActorFlow https://doc.akka.io/docs/akka/current/stream/operators/ActorFlow/ask.html

@fmeeuw
Copy link
Author

fmeeuw commented Sep 8, 2018

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.

@2m
Copy link
Member

2m commented Sep 25, 2018

I think adding functionality that sends stream completion signal or error makes sense.

Also the "more detached version" could be implemented using wireTap (does not backpressure main stream) or alsoTo backpressures main stream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants