Skip to content
GitHub

Configuration

The config section is "resilience". Environment variable prefix is LEX_RESILIENCE__.

Top-level config. Root section in application.yaml:

resilience:
circuit_breaker:
failure_threshold: 5
recovery_timeout: 60.0
retry:
max_attempts: 3
base_delay: 1.0
bulkhead:
max_concurrent: 10
timeout:
timeout: 30.0
KeyTypeDefaultEnv VarDescription
failure_thresholdint5LEX_RESILIENCE__CIRCUIT_BREAKER__FAILURE_THRESHOLDFailures before the circuit opens
recovery_timeoutfloat60.0LEX_RESILIENCE__CIRCUIT_BREAKER__RECOVERY_TIMEOUTSeconds in OPEN state before HALF-OPEN
expected_exceptiontuple[type[Exception], ...](Exception,)Exception types counted as failures
success_thresholdint3LEX_RESILIENCE__CIRCUIT_BREAKER__SUCCESS_THRESHOLDConsecutive successes to close from half-open
timeoutfloat30.0LEX_RESILIENCE__CIRCUIT_BREAKER__TIMEOUTPer-call timeout in seconds
namestr""Human-readable identifier
sliding_window_secondsfloat60.0LEX_RESILIENCE__CIRCUIT_BREAKER__SLIDING_WINDOW_SECONDSWindow for computing failure rate
failure_rate_thresholdfloat0.5LEX_RESILIENCE__CIRCUIT_BREAKER__FAILURE_RATE_THRESHOLDFraction of calls that must fail to trip
backendLiteral["memory", "redis", "consul"]"memory"Distributed coordination backend
KeyTypeDefaultEnv VarDescription
max_attemptsint3LEX_RESILIENCE__RETRY__MAX_ATTEMPTSTotal attempts including initial try
base_delayfloat1.0LEX_RESILIENCE__RETRY__BASE_DELAYInitial delay in seconds
max_delayfloat60.0LEX_RESILIENCE__RETRY__MAX_DELAYMaximum delay cap
backoff_factorfloat2.0LEX_RESILIENCE__RETRY__BACKOFF_FACTORExponential backoff multiplier
jitter`boolfloat`TrueLEX_RESILIENCE__RETRY__JITTER
retry_ontuple[type[Exception]](Exception,)Exception types that trigger retry
abort_ontuple[type[Exception]]()Exception types that abort retry
retry_on_result`CallableNone`None
abort_if`CallableNone`None
KeyTypeDefaultEnv VarDescription
max_concurrentint10LEX_RESILIENCE__BULKHEAD__MAX_CONCURRENTMaximum concurrent requests
queue_sizeint100LEX_RESILIENCE__BULKHEAD__QUEUE_SIZEMaximum queue size
timeoutfloat30.0LEX_RESILIENCE__BULKHEAD__TIMEOUTExecution timeout
namestr""Bulkhead name
KeyTypeDefaultEnv VarDescription
timeoutfloat30.0LEX_RESILIENCE__TIMEOUT__TIMEOUTOperation timeout in seconds
timeout_messagestr"Operation timed out"Timeout error message

Configured separately through IdempotencyConfig or via IdempotencyProvider. Env prefix LEX_RESILIENCE__IDEMPOTENCY__.

KeyTypeDefaultEnv VarDescription
ttlint3600LEX_RESILIENCE__IDEMPOTENCY__TTLTTL for cached results (seconds)
max_entriesint10000LEX_RESILIENCE__IDEMPOTENCY__MAX_ENTRIESMax in-memory entries before FIFO eviction
cleanup_intervalfloat300.0LEX_RESILIENCE__IDEMPOTENCY__CLEANUP_INTERVALBackground cleanup sweep interval
auto_cleanupboolTrueLEX_RESILIENCE__IDEMPOTENCY__AUTO_CLEANUPStart background cleanup on init
key_prefixstr"idempotency:"LEX_RESILIENCE__IDEMPOTENCY__KEY_PREFIXPrefix for backing-store keys
max_key_lengthint512LEX_RESILIENCE__IDEMPOTENCY__MAX_KEY_LENGTHMaximum idempotency key length
resilience:
circuit_breaker:
failure_threshold: 10
recovery_timeout: 30.0
backend: "memory"
retry:
max_attempts: 5
base_delay: 0.5
backoff_factor: 1.5
bulkhead:
max_concurrent: 20
queue_size: 200
timeout:
timeout: 15.0

Env var override form:

Terminal window
export LEX_RESILIENCE__RETRY__MAX_ATTEMPTS=5
export LEX_RESILIENCE__CIRCUIT_BREAKER__RECOVERY_TIMEOUT=30.0