Skip to content

Detect failures and encapsulate the logic of preventing a failure from constantly recurring

License

Notifications You must be signed in to change notification settings

trimentor/jquery-circuitbreaker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

jquery-circuitbreaker

Detect failures and encapsulate the logic of preventing a failure from constantly recurring

Usage

var remoteFn = function () {
  return $.ajax({
    url: '/api/might-fail',
    timeout: 3000
  });
};

var circuitBreaker = new CircuitBreaker(remoteFn, {
  failureTreshold: 3 // Default "5"
});

circuitBreaker.fire().done(function () {
  // Happy path
  console.log('Circuit closed!');
}).fail(function (error) {
  // Unhappy path
  console.log('Circuit open!');
});

About

Detect failures and encapsulate the logic of preventing a failure from constantly recurring

Resources

License

Stars

Watchers

Forks

Packages

No packages published