Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
  test
  src
  .github
  Jenkinsfile
  Makefile
  package.json
  README.md
Size: Mime:
  README.md

goat

Local's Node module for backing off and scaling up calls.

Usage

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);
  });
}

new Goat(options)

The goat constructor function takes an options object as its only parameter. Input is merged with defaults below, so not all properties are required.

options

func

The 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.

factor

The exponential factor used for backing off executing schedule (default = 5).

floorMs

The starting value for a back off amount in milliseconds (default = 1).

ceilingMs

The highest value for a back off amount in milliseconds (default = 5000).

maxFunc

The maximum number of concurrently running task to scale to (default = 3).

Methods

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.

Download

Gemfury

Gemfury Info

Setup your project to proxy from Gemfury

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

Maintenance

Configure Project

Install the dependencies for this project.

npm run clean

Test Project

Run mocha test for this project.

npm test

Push Build to Gemfury

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