ChaosConfig

Configuration for the chaos policy, used to inject faults, latency, or overridden results into an operation for testing and resilience validation.

Production safeguard: enabled defaults to false. The chaos wrapper is only installed when enabled is explicitly set to true. This ensures zero overhead in production.

Example:

resilient(scope) {
chaos {
enabled = true
failureRate = 0.3 // 30% of calls throw
latency = 200.milliseconds // inject 200ms delay before every call
exception = { IOException("chaos: simulated network failure") }
}
}

See also

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Whether the chaos policy is active.

Link copied to clipboard
var exception: () -> Throwable?

Factory for the exception to throw when a fault is injected.

Link copied to clipboard

Probability of injecting a fault on each call. Range: 0.0 (never) to 1.0 (always).

Link copied to clipboard
var injectResult: () -> Any??

If set, overrides the block's return value when no fault fires.

Link copied to clipboard

Optional delay to inject before executing the block. null means no delay.