These are chat archives for akkadotnet/AkkaStreams

11th
Oct 2016
Sean Farrow
@SeanFarrow
Oct 11 2016 06:32
Assuming I've got a graph stage, is it possible to retry the previous stage or wrap a stage in some logic. Essentially I'm thinking of the case where I get a 500 back from a web server. I'm using Polly to do this, as it will provide caching in the future, so would like to continue with this. I've looked at the Deciders and it appears I can't do what I want with those, i.e wait for a period of time if a failure occurs as I could in Akka. I could add my retry logic to each stage individually, but given it's a reusable piece, I don't want to have to write it more than once!
Marc Piechura
@marcpiechura
Oct 11 2016 17:05
@SeanFarrow if you want to use Polly I think you need to build a custom stage, if you want a simple retry you could build a loop inside a graph that sends failed requests again
Basically you take two inputs, one from the normal graph and one from the loop then comes your request stage and then you have two outputs one sends failed request back to the input and the other ones sends the successful requests downstream
I think we have an example somewhere in the docs
Sean Farrow
@SeanFarrow
Oct 11 2016 17:44
Ok, I'll build a custom logic stage. If a source or any graph stage fails, how can I handle this, i.e OnFailure/OnComplete, is it just tasks again? I'm piping back to the actor that I'm running from if that helps.
Marc Piechura
@marcpiechura
Oct 11 2016 18:16
@SeanFarrow you need to handle the task failure inside your custom stage, if you call FailStage or CompleteStage you're stopping the stream. Maybe the best resource is Ops.cs , all build in stages (select/where..) are also only custom graph stages and should give you an good overview of how you can build your own and what you need to take into account when you're working with tasks ( use GetAsyncCallback for continuation)
Sean Farrow
@SeanFarrow
Oct 11 2016 19:00
Thanks marc, If a stream fails what happends in terms of tasks/messages?
Marc Piechura
@marcpiechura
Oct 11 2016 20:02
A failure is propagated from the source downstream until it reached the sink, when a stage received a failure it can react and for example cleanup some resources or even "mute" the failure and keep going, for example Recover replaces the failed upstream part with a new source in case of failure. So for your tasks you can cancel them, wait until they finished and then propagate the failure downstream or immediately propagate the failure downstream which is the default behavior