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

@allingeek-gremlin/failure-flags

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@allingeek-gremlin/failure-flags

Failure Flags is a node SDK for working with the Gremlin fault injection platform to build application-level chaos experiments and reliability tests. This library works in concert with Gremlin-Lambda, a Lambda extension, or Gremlin-Container a conatiner s

  • 0.0.10
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

failure-flags-node

Failure Flags is a node SDK for working with the Gremlin fault injection platform to build application-level chaos experiments and reliability tests. This library works in concert with Gremlin-Lambda, a Lambda extension, or Gremlin-Container a conatiner sidecar agent. This architecture minimizes the impact to your application code, simplifies configuration, and makes adoption painless.

Just like feature flags, Failure Flags are safe to add to and leave in your application. Failure Flags will always fail safe if it cannot communicate with its sidecare or its sidecar is misconfigured.

You can get started by adding @gremlin/failure-flags to your package dependencies:

npm i --save @allingeek-gremlin/failure-flags

Then instrument the the part of your application where you want to inject faults.

const failureflags = require(`@allingeek-gremlin/failure-flags`);

...

await failureflags.ifExperimentActive({
  name: 'flagname',                 // the name of your failure flag
  labels: {})                       // additional attibutes about this invocation

...

The best spots to add a failure flag are just before or just after a call to one of your network dependencies like a database or other network service. Or you can instrument your request handler and affect the way your application responses to its callers. Here's a simple Lambda example:

// Note: you must bring in the failure-flags library
const gremlin = require('@allingeek-gremlin/failure-flags');

module.exports.handler = async (event) => {
  start = Date.now();

  // If there is an experiment defined for this failure-flag, that is also
  // targeting the HTTP method and or path then this will express the 
  // effects it describes.
  await gremlin.ifExperimentActive({
    name: 'http-ingress',
    labels: { 
      method: event.requestContext.http.method,
      path: event.requestContext.http.path }});

  return {
    statusCode: 200,
    body: JSON.stringify(
      {processingTime: Date.now() - start, timestamp: event.requestContext.time},
      null,
      2
    ),
  };
};

You can always bring your own behaviors and effects by providing a behavior function. Here's another Lambda example that writes the experiment data to the console instead of changing the application behavior:

// Note: you must bring in the failure-flags library
const gremlin = require('@allingeek-gremlin/failure-flags');

module.exports.handler = async (event) => {
  start = Date.now();

  // If there is an experiment defined for this failure-flag, that is also
  // targeting the HTTP method and or path then this will express the 
  // effects it describes.
  await gremlin.ifExperimentActive({
    name: 'http-ingress',
    labels: { 
      method: event.requestContext.http.method,
      path: event.requestContext.http.path },
    behavior: async (experiment) => {
      console.log('handling the experiment', experiment);
    }});

  return {
    statusCode: 200,
    body: JSON.stringify(
      {processingTime: Date.now() - start, timestamp: event.requestContext.time},
      null,
      2
    ),
  };
};

Keywords

FAQs

Package last updated on 26 Mar 2023

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