Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

charlie

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

charlie

Charlie knows

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

Charlie is a node module keeps of success and failures of network requests and adises on a delay between attempts using the backoff algorithm described in Exponential Backoff in Distributed Systems.

This module applies skips upto three failures before starting the backoff.

Travis status

Getting Charlie

npm install charlie

Usage

charlie.ask

Before making a request to an origin, let charlie know. This functiont akes three arguments:

  • keys: An array of keys used to identify the network resource. For HTTP requests, the keys could be the URI of the resource, or the IP address, or the host name etc.
  • initTimeout: Initial timeout. As suggested in the blog post above, choose a value under which 99% of requests complete.
  • maxDelay: Maximum backoff delay. Choose an acceptable value based on availability requirements.

This function returns a decision with three fields:

  • state: values are go or nogo

  • count: number of failures so far. The count is reset after a success.

  • delay: currently applied backoff delay

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

charlie.ok

When a request succeeds, tell charlie.

charlie.ok(arr);

charlie.notok

When the request fails, tell charlie any way.

charlie.notok(arr);

charlie.clear

Forget everything about the resource.

charlie.clear(arr);

FAQs

Package last updated on 03 May 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc