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

external interface is missing #42

Open
vitaly-t opened this issue Jun 18, 2017 · 1 comment
Open

external interface is missing #42

vitaly-t opened this issue Jun 18, 2017 · 1 comment

Comments

@vitaly-t
Copy link

vitaly-t commented Jun 18, 2017

It doesn't seem right that a retry loop can only be interrupted (or interacted with) form inside the callback.

There are many scenarios when it needs to happen externally.

Function retry should return an object/interface for stopping, and even monitoring the current status:

var r = retry(cb);

if(/*something happenned*/ && r.attempts > 3) {
   r.stop();
   // or even with a reason:
   // r.stop(new Error('Had to stop externally'));
}

also, how about pausing the retries?

r.pause(); // pause unconditionally
// or
r.pause(100); // pause for 100 millisecond
// and resume:
r.resume(); // to resume the retries, if currently paused

plus access to the current status:

r.getStatus() // = running | finished | paused
@demmer
Copy link
Owner

demmer commented Jun 19, 2017

At a high level I can see how this could be a nice addition to the project -- if you have an implementation with tests I'd be happy to review and include it but I'm not actively doing much if any development on this.

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

2 participants