chaos-middleware
Express middleware for chaos testing
Usage
const chaos = const express = const app = const options = probability: 05 rules: event: 'httpStatus' params: 500 app
chaos(options)
create a chaos middleware instance.
options
Objectprobability
Number (default = 0.1) - probability that is chaos happens. (0.0 - 1.0)rules
Array - rules for chaos.
Rule
event
String - event name. (eg.httpStatus
)params
Any - parameter for the event.weight
Number ( defualt = 1) - weight for select this rule among the rules.
Events
An event is a function exposed in chaos.events
.
events.httpStatus(status)
Return response with specific status code.
status
Number - status code.
events.delay(amount)
Return normal response with some delay.
amount
Number - millseconds to delay.
events.close()
Close connections.
events.exit(exitCode = 1)
Exit node process.
exitCode
Number - exit code.
events.kill(signal = "SIGHUP")
Send the signal to self process.
signal
Number|String - the signal name or number.
events.throwError(err)
Throw err
.
err
Any - An error to throw.
events.reject(err)
Rise unhandledRejection
.
err
Any - An error to reject promises.