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

Notification function as interface of BackOffs. #116

Open
thediveo opened this issue Jul 19, 2021 · 0 comments
Open

Notification function as interface of BackOffs. #116

thediveo opened this issue Jul 19, 2021 · 0 comments

Comments

@thediveo
Copy link

thediveo commented Jul 19, 2021

At this time, backoff supports the usecase well, where the code calling RetryNotify(b, n) is either directly related to the notification function passed or at least got it passed in explicitly along with a particular backoff.

When RetryNotify(...) is deeper in a layered architecture then a higher layer or the upmost layer might be interested in notifications instead, as it is the ultimate consumer as well as the originator of the backoff. In order to avoid having all intermediate layers having to be made aware of notification callbacks, would it be possible to attach notification callbacks to the backoff objects themselves?

This would allow the source of backoff information to also be able to get ultimately informed about any retries without much hassle.

Some use cases might be service logging by the ultimate service as to not having to instrument lower layer modules with logging and specific loggers (a nightmare in itself), as well as easy uni test instrumentation.

    cbo := NewConstantBackOff(42*time.Seconds, WithNotify(func(){ /* ... */ }))
    ebo := NewExponentialBackOff(WithNotify(func(){ /* ... */ }))

This might be easier to achieve in terms of API with the "builder pattern" issue #106 in place.

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

1 participant