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

Supervisor restart should allow for exponential backoff on retry #146

Closed
rtyler opened this issue Dec 30, 2019 · 2 comments
Closed

Supervisor restart should allow for exponential backoff on retry #146

rtyler opened this issue Dec 30, 2019 · 2 comments
Labels
A-supervisor Area: Supervisor related issues C-feature-request Category: Feature Request enhancement New feature or request

Comments

@rtyler
Copy link

rtyler commented Dec 30, 2019

Is your feature request related to a problem? Please describe.

For some failure models, such as a client trying to connect to a server which is offline, the current supervision model will effectively loop { connect(); } over and over again, with no "safe" backoff on retrying the child.

Describe the solution you'd like

Ideally, I would like to specify an ExponentialBackOff strategy for my supervisor, such that when children hit failures, the process will not simply consume 100% CPU trying to retry the child.

backoff is an example implementation that works on arbitrary closures, which may be worth borrowing code or ideas from.

Describe alternatives you've considered

Me manually putting a thread sleep into the child doesn't seem like a good idea 😸

@vertexclique vertexclique added A-supervisor Area: Supervisor related issues C-feature-request Category: Feature Request enhancement New feature or request labels Dec 30, 2019
@rtyler
Copy link
Author

rtyler commented Dec 30, 2019

My temporary workaround is to add a map_err to my workers where I invoke connect (a predictable source of errors):

                let (mut socket, response) =
                    connect(Url::parse("ws://localhost:8000/ws/").unwrap())
                    .map_err(|e| {
                        error!("Failed to connect!");
                        sleep(Duration::from_secs(1));
                    }).expect("Can't connect");

@vertexclique
Copy link
Member

This is now implemented in #157 . Closing… :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-supervisor Area: Supervisor related issues C-feature-request Category: Feature Request enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants