Home

Awesome

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:

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

0.1.0

...

License

Copyright (c) 2020

Licensed under the MIT license.