ChaosEngine

class ChaosEngine(initialStage: Stage = Wait) : Filter

The Chaos Engine controls the lifecycle of applying Chaotic behaviour to traffic, which is exposed as a standard Http4k Filter. Chaos can be programmatically updated and enabled/disabled. By default, the engine is deactivated, so activate() needs to be called to witness any change in behaviour,

Constructors

Link copied to clipboard
constructor(behaviour: Behaviour)
constructor(initialStage: Stage = Wait)

Functions

Link copied to clipboard

Converts this chaos stage to a standard http4k Filter.

Link copied to clipboard

Turn off Chaos Engine. No Chaotic behaviour will be applied.

Link copied to clipboard

Turn on Chaos Engine using the pre-initialised chaotic behaviour. Note that this may not actually produce any effect based on the configured behaviour (e.g. if there is a specific Trigger that is condition-based.)

fun enable(stage: Stage): ChaosEngine

Update the new complex (multi-stage, triggers etc) Chaotic behaviour to be applied whenever the ChaosEngine is enabled.

fun enable(behaviour: Behaviour): ChaosEngine

Update with new simple Chaotic behaviour to be applied whenever the ChaosEngine is enabled.

Link copied to clipboard
open operator override fun invoke(p1: HttpHandler): (request: Request) -> Response
Link copied to clipboard

Check if the configured Chaos behaviour is currently being applied to all traffic.

Link copied to clipboard
fun Stage.then(nextStage: Stage): (Request) -> Filter?

Chain the next ChaosBehaviour to apply when this stage is finished.

Link copied to clipboard
open override fun toString(): String

Outputs description of the current state.

Link copied to clipboard
fun Stage.until(trigger: Trigger): Stage

Stop applying the ChaosBehaviour of this stage when the ChaosTrigger fires.

Link copied to clipboard
fun HttpHandler.withChaosApi(engine: ChaosEngine = ChaosEngine(), security: Security = NoSecurity, controlsPath: String = "/chaos", openApiPath: String = "", corsPolicy: CorsPolicy = UnsafeGlobalPermissive, clock: Clock = Clock.systemUTC(), apiName: String = "http4k"): RoutingHttpHandler

Mixin the set of remote Chaos API endpoints to a standard HttpHandler, using the passed ChaosStage. Optionally a Security can be passed to limit access to the chaos controls.