包详细信息

@flystorage/chaos

duna-oss3.2kMIT1.1.0

A storage adapter decorator with the ability to stage errors.

testing, chaos, resillience, flystorage

自述文件

Flystorage adapter for chaos engineering

This package contains an adapter decorator that causes instrumented failures.

Installation

Install all the required packages

npm install --save @flystorage/file-storage @flystorage/chaos

Setup

import {FileStorage} from '@flystorage/file-storage';
import {ChaosStorageAdapterDecorator, TriggeredErrors} from '@flystorage/chaos';

const strategy = new TriggeredErrors();
const adapter = new ChaosStorageAdapterDecorator(
    createActualAdapter(),
    strategy,
);
const storage = new FileStorage(adapter);

⚠️ Always use the FileStorage, it is essential for security and a good developer experience. Do not use the adapter directly.

Usage


import {TriggeredErrors} from '@flystorage/chaos';

const strategy = new TriggeredErrors();

// error on all write calls
strategy.on('write', () => new Error());

// error on first 2 stat calls
strategy.on('stat', () => new Error(), {times: 2});

// error after first 2 deleteFile calls
strategy.on('deleteFile', () => new Error(), {after: 2});

// error on 2nd and 3rd call to any method
strategy.on('*', () => new Error(), {after: 1, times: 2});

更新日志

@flystorage/chaos

1.1.0

Changes

  • Added AbortSignal support

1.0.0

Major Changes

  • First 1.0.0 release