Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Charlie knows best
branch: master

This branch is 9 commits behind ql-io:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
.npmignore
.travis.yml
README.md
package.json

README.md

Charlie is a utility that implements the backoff algorithm described in Exponential Backoff in Distributed Systems.

The usage is simple. Before making a request to an origin, let charlie know.

// arr is an array of strings used as a key
// timeout and maxDelay are in msec
var decision = charlie.ask(arr, timeout, maxDelay);
if(decision.state === 'go') {
    // make the request
}
else {
    // don't make the request
    console.log('Waiting until ' + decision.delay);
}

When the request succeeds, let Charlie know.

charlie.ok(arr);

When the request fails, let Charlie know.

charlie.notok(arr);
Something went wrong with that request. Please try again.