Package-level declarations

Types

Link copied to clipboard
abstract class Behaviour : Filter

Encapsulates the type of bad behaviour to apply to the response.

Link copied to clipboard
Link copied to clipboard
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,

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract class ChaoticHttpHandler : Function1<request: Request, Response>

Useful for creating HttpHandlers with a built-in Chaos Engine API for enabling and disabling chaos.

Link copied to clipboard

A set of endpoints to an application which will control the setting and toggling chaos behaviour. The added endpoints are: GET //status <- check the on off/status of the injected chaos POST //activate <- turn on the chaos. optionally POST a JSON body to set a list of new stages to use. POST //deactivate <- turn off the chaos POST //toggle <- toggle the chaos

Link copied to clipboard
typealias Stage = (Request) -> Filter?

Defines a periodic element during which a particular ChaosBehaviour is active.

Link copied to clipboard
fun interface Trigger : Function1<Request, Boolean>

Properties

Link copied to clipboard

Local URI for this ChaoticHttpHandler

Link copied to clipboard

Calculate a random standard port number for a ChaoticHttpHandler using the classname as a seed

Functions

Link copied to clipboard
infix fun Trigger.and(that: Trigger): Trigger
Link copied to clipboard
Link copied to clipboard

Converts this chaos stage to a standard http4k Filter.

Link copied to clipboard
fun JsonNode.asStage(clock: Clock = Clock.systemUTC()): Stage
Link copied to clipboard
operator fun Trigger.not(): Trigger
Link copied to clipboard
infix fun Trigger.or(that: Trigger): Trigger
Link copied to clipboard
fun ChaoticHttpHandler.start(port: Int = this::class.defaultPort, serverConfig: (Int) -> ServerConfig = ::SunHttp): Http4kServer

Convert this ChaoticHttpHandler into a running server, defaulting on a port dependent on the classname.

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
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.