Nocturnal Pumpkin Maelstrom

    feathers-opossum
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.2 • Public • Published

    feathers-opossum

    Build Status Coverage Status dependencies Status Known Vulnerabilities

    feathers-opossum is a circuit breaker for Feathers services. It implements the opossum module.

    npm install feathers-opossum --save
    

    API

    service(Service, serviceOptions, opossumOptions)

    Example:

    const service = require('service');
    const opossumService = require('feathers-opossum');
     
    const options = {
      opossum: {
        timeout: 3000,
        errorThresholdPercentage: 50,
        resetTimeout: 30000
      },
      fallback: () => {
        return 'Sorry, out of service right now';
      },
      events: {
        fallback: result => reportFallbackEvent(result),
      }
      methods: ['find', 'get']
    };
     
    const circuitedService = opossumService(service, {id:'_id', paginate: {max:10 }, options);
     
    app.use('/may-fail', circuitedService);

    Options:

    • Service (required) - The main service
    • opossum.timeout (optional, default: 3000) - If our function takes longer than trigger a failure
    • opossum.errorThresholdPercentage (optional, default: 50) - When this ratio on requests fail, trip the circuit
    • opossum.resetTimeout (optional, default: 30000) - After this try again.
    • fallback - A fallback function that will be executed in the event of failure.
    • events - Opossum event listener.

    Options per Service Method:

      const options = {
          find: {
            opossum: {
              timeout: 5000,
              errorThresholdPercentage: 50,
              resetTimeout: 30000
            }
            fallback: () => {
              return 'Sorry, out of service right now';
            },
            events: {
              fallback: result => reportFallbackEvent(result),
            }
          },
          get: {
            opossum: {
              timeout: 1000,
              errorThresholdPercentage: 50,
              resetTimeout: 30000
            }
            fallback: () => {
              return 'Sorry, out of service right now';
            },
            events: {
              fallback: result => reportFallbackEvent(result),
            }
          }
        };

    Changelog

    1.0.0

    • implement opossum events
    • add event test

    0.1.0

    • publish

    ...

    License

    Copyright (c) 2020

    Licensed under the MIT license.

    Install

    npm i feathers-opossum

    DownloadsWeekly Downloads

    2

    Version

    1.0.2

    License

    none

    Unpacked Size

    9.27 kB

    Total Files

    8

    Last publish

    Collaborators

    • sajov