chaos

fun chaos(block: ChaosConfig.() -> Unit)

Configures the chaos policy for fault injection.

Production safeguard: the policy is only installed when ChaosConfig.enabled is explicitly set to true. When disabled (the default), zero overhead is added — no wrapper is created.

Chaos is positioned as the innermost wrapper (just before the user block) so it directly controls what the block sees: latency, faults, or overridden results.

Example:

resilient(scope) {
chaos {
enabled = true // MUST be set — false by default
failureRate = 0.3 // 30% of calls throw
latency = 100.milliseconds
}
}

Parameters

block

Lambda to configure ChaosConfig.