PaperTiger.Plug.APIChaos (PaperTiger v0.9.21)
View SourcePlug middleware that injects chaos into API requests.
When API chaos is configured via PaperTiger.ChaosCoordinator, this plug
may randomly:
- Timeout requests (sleep then return 504)
- Return rate limit errors (429)
- Return server errors (500/502/503)
Configuration
PaperTiger.ChaosCoordinator.configure(%{
api: %{
timeout_rate: 0.02, # 2% of requests timeout
timeout_ms: 5000, # How long to sleep before 504
rate_limit_rate: 0.01, # 1% get 429
error_rate: 0.01, # 1% get 500/502/503
endpoint_overrides: %{
"/v1/subscriptions" => :rate_limit # Always rate limit this endpoint
}
}
})