Repository URL to install this package:
|
Version:
2.0.1 ▾
|
| test |
| src |
| .github |
| Jenkinsfile |
| Makefile |
| package.json |
| README.md |
Local's Node module for backing off and scaling up calls.
var Goat = require("goat"); var goat = new Goat({ func: yourProcess }); goat.start(); function yourProcess(){ return new Promise((resolve, reject) => { // business logic if (businessLogicFailure) { return reject(false); } return resolve(true); }); }
The goat constructor function takes an options object as its only parameter. Input is merged with defaults below, so not all properties are required.
optionsfuncThe function passed to Goat to execute once backoff time is reached. If this is not passed in through the options parameter, it must be passed in through the goat.start(func) method.
Note that the function needs to return a promise, thenable, or resolve for the auto scaling to work. The promise is used to control in the sempahore flow. If the promise contains a value of true or false, then it will be interpreted for a follow up reset (true) or backoff (false) flow.
factorThe exponential factor used for backing off executing schedule (default = 5).
floorMsThe starting value for a back off amount in milliseconds (default = 1).
ceilingMsThe highest value for a back off amount in milliseconds (default = 5000).
maxFuncThe maximum number of concurrently running task to scale to (default = 3).
start([func])Use to kick off the goat processes.
Optionaly supply a func here if it was not supplied in the above options parameter or if the func needs to be overwritten.
reset()Use when you want the supplied func to keep at max call frequency
var options = { func : yourProcess, maxFunc : 3 }; var goat = new Goat(options); goat.start(); // 1 func goat.reset(); // 2 func goat.reset(); // 3 func goat.reset(); //3 func
backoff()Use when you want the supplied func to keep at lower call frequency
var options = { func : yourProcess, maxFunc : 3 }; var goat = new Goat(options); goat.start(); // 1 func goat.backoff(); // 1 func goat.reset(); // 2 func goat.reset(); // 3 func goat.reset(); //3 func goat.backoff(); //1 func
stop()Use to stop the goat processes.
Create a .npmrc file at the root of your application. The registry path should use our group user account.
registry=https://npm-proxy.fury.io/P2NoU4CksQg5WPReyUxy/xogroupinc/ strict-ssl=true ca=
After, run the below command
npm install --save goat
Install the dependencies for this project.
npm run clean
Run mocha test for this project.
npm test
This will run all of the test, npm pack the build to /builds/Release and then finally push the package to Gemfury
npm run build