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

Is there any OnSuccess Action like OnRetry for policy to notify the attempt when it got fixed #288

Closed
sudheer524 opened this issue Aug 3, 2017 · 3 comments

Comments

@sudheer524
Copy link

Hi

I am trying to reuse creating policy and track the attempts and log exceptions while retry.

Is there a way to handle on success in policy itself to notify the user that call was successful in particular attempt

@reisenberger
Copy link
Member

@sudheer524 There is not.

We could consider adding this; if so, it would be done after the major syntax refactor implied by #281. #281 would move policy hook delegates into a fluent postfix syntax. This will make adding further policy hook delegates easier, without proliferating additional overloads.

@reisenberger
Copy link
Member

Similarly to the comment in #336, the Polly events-for-metrics intended for Polly v6.0, should include a SucceededWithRetries event (or similar), indicating the number of retries involved in succeeding.

If that event is provided, reconsider whether the extra OnSuccess delegate hook for the retry policy discussed above is necessary.

@reisenberger
Copy link
Member

This is similar to #383 (logging eventual failure) and #336 (logging initial attempt).

The best way for Polly to provide a solution for this would probably be to hook into a future emitted Policy event such as CompletedWithSuccess or SucceededWithRetries (which would be emitted automatically rather than extending the API surface in its current form). (cf: #336 (comment)).

Like #383, logging eventual success could also be achieved by using .ExecuteAndCapture/Async(...) overloads, perhaps using also the execution Context to capture the number of tries which have been attempted. This could be wrapped in an extension method to easily apply it to every execution, if desired.

Thanks @sudheer524 for raising this! It provides useful food for thought about cases which policy events should support.

This does feel like a strong case to support: knowing (say, on average) how many attempts were needed to achieve success.

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

No branches or pull requests

2 participants