0.10.1 • Published 3 years ago

@dazn/chaos-squirrel-runner-middy v0.10.1

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

@dazn/chaos-squirrel-runner-middy

Integrate the Chaos Runner into your Middy middleware.

Usage

import chaosRunnerMiddleware from '@dazn/chaos-squirrel-runner-middy';
import ChaosRunner from '@dazn/chaos-squirrel-runner';
import CPUAttack from '@dazn/chaos-squirrel-attack-cpu';
import middy from '@middy/core';

const createRunner = ChaosRunner.configure({
  probability: 1,
  possibleAttacks: [
    {
      probability: 0.01,
      createAttack: CPUAttack.configure({ allowLoopEvery: 10 }),
    },
  ],
});

const originalHandler = async () => {
  // your lambda here
  // there may be some chaos going on!
};

const handler = middy(originalHandler).use(
  chaosRunnerMiddleware({
    createRunner,
    wait: true,
    createLogger: (context) => {
      return (level, message, details) => {
        // call a logger which is attached to the lambda context
        context.logger[level](message, details);
      };
    },
  })
);

export { handler };

Middy Runner Arguments

ParameterTypeDefaultDescription
createRunnerFunction-A function which returns a new instance of ChaosRunner
waitBooleantrueWhether to wait for async chaos functions to complete, for example waiting for all files to be created for the open files attack
createLoggerFunction-Optional. A function which is called with the Lambda context, which must return a valid logger function (see Chaos Runner for logger docs). This is useful when the context has a custom logger or correlation IDs attached, which you want to include in any logs
0.10.1

3 years ago

0.10.0

3 years ago

0.9.9

3 years ago

0.9.8

3 years ago

0.9.7

3 years ago

0.9.5

3 years ago

0.9.4

4 years ago

0.9.3

4 years ago

0.9.2

4 years ago

0.9.1

4 years ago

0.9.0

4 years ago

0.8.0

4 years ago

0.7.0

4 years ago

0.6.0

4 years ago

0.5.0

4 years ago