How to use backo2 - 3 common examples

To help you get started, we’ve selected a few backo2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github weapp-socketio / wxapp-socket-io / src / manager.js View on Github external
function Manager(uri, opts) {
  if (!(this instanceof Manager)) return new Manager(uri, opts)

  opts.path = opts.path || 'socket.io'
  this.nsps = {}
  this.subs = []
  this.opts = opts
  this.uri = uri
  this.readyState = 'closed'
  this.connected = false
  this.reconnection(opts.reconnection !== false)
  this.reconnectionAttempts(opts.reconnectionAttempts || Infinity)
  this.reconnectionDelay(opts.reconnectionDelay || 1000)
  this.reconnectionDelayMax(opts.reconnectionDelayMax || 5000)
  this.randomizationFactor(opts.randomizationFactor || 0.5)
  this.backoff = new Backoff({
    min: this.reconnectionDelay(),
    max: this.reconnectionDelayMax(),
    jitter: this.randomizationFactor(),
  })
  this.timeout(null == opts.timeout ? 20000 : opts.timeout)
  this.encoder = encoder
  this.decoder = decoder
  this.connecting = []
  this.autoConnect = opts.autoConnect !== false
  if (this.autoConnect) this.open()
}
github Coding / WebIDE-Frontend / app / utils / getBackoff.js View on Github external
export default function getBackoff (config={}) {
  config = { ...defaultConfig, ...config }
  const backoff = new Backoff({
    min: config.delayMin,
    max: config.delayMax,
    jitter: 0.5,
  })

  return backoff
}
github michalkvasnicak / aws-lambda-graphql / packages / aws-lambda-graphql / src / client / client.ts View on Github external
constructor({
    uri,
    options: {
      lazy = false,
      operationTimeout = Infinity,
      reconnect = false,
      reconnectAttempts = Infinity,
    } = {},
    webSockImpl = NativeWebSocket,
  }: Options) {
    const backoff = new Backoff({ jitter: 0.5 });

    if (webSockImpl == null) {
      throw new Error(
        'Not native WebSocket implementation detected, please provide an implementation',
      );
    }

    this.lazy = lazy;
    this.ee = new EventEmitter.EventEmitter() as any;
    this.operationProcessor = new OperationProcessor({ operationTimeout });
    this.machine = interpret(
      clientMachine.withContext({
        backoff,
        reconnect,
        reconnectAttempts,
        uri,

backo2

simple backoff based on segmentio/backo

MIT
Latest version published 10 years ago

Package Health Score

65 / 100
Full package analysis

Popular backo2 functions