activation
Activation-aware retry logic for cold-start tolerance.
When KEDA scales an agent to 0 replicas, the first request may encounter:
- 503 Service Unavailable (interceptor buffering, no backend yet)
- Connection refused (pod not started)
- 504 Gateway Timeout (cold start exceeded upstream timeout)
This module provides configurable retry with exponential backoff and jitter to handle these transient failures transparently.
Use [Client::call_with_activation] for activation-aware A2A calls, or
[retry_with_activation] for generic retry over any async callable.
Structs
Section titled “Structs”ActivationConfig
Section titled “ActivationConfig”Configuration for activation-aware retries when calling potentially cold agents.
These values drive the SDK-side retry budget. The KEDA HTTP Add-on
HTTPScaledObject does NOT have a CRD-level queueDepth — this is the
platform’s enforcement layer.
Fields
| Field | Type | Description |
|---|---|---|
max_cold_start_timeout | Duration | Max time to wait for a cold agent to respond. Default: 5s. |
initial_backoff | Duration | Initial retry delay. Default: 100ms. |
max_backoff | Duration | Max retry delay cap. Default: 2s. |
max_retries | u32 | Max retries before giving up. Default: 3. |
jitter | bool | Add jitter to backoff. Default: true. |
Methods
backoff_for_attempt
Section titled “backoff_for_attempt”fn backoff_for_attempt(&self, attempt: u32) -> DurationCompute the backoff duration for a given attempt (0-indexed).
Uses exponential backoff: initial * 2^attempt, capped at max_backoff.
When jitter is enabled, the result is multiplied by a factor in [0.5, 1.0].
is_retriable_status
Section titled “is_retriable_status”fn is_retriable_status(status: u16) -> boolCheck if an HTTP status code indicates a retriable cold-start scenario.
is_retriable_error
Section titled “is_retriable_error”fn is_retriable_error(error_msg: &str) -> boolCheck if an error message indicates a retriable connection failure.
Functions
Section titled “Functions”idempotency_key
Section titled “idempotency_key”fn idempotency_key(request_id: &str, attempt: u32) -> StringGenerate an idempotency key for safe retries on state-mutating requests.
Format: {request_id}:{attempt} — the server should deduplicate by this key.
activation_delay
Section titled “activation_delay”async fn activation_delay(duration: Duration)Async delay for activation retries. Uses tokio::time::sleep on native
and std::thread::sleep (WASI monotonic clock) on WASM.
retry_with_activation
Section titled “retry_with_activation”async fn retry_with_activation<T, E, F, Fut>(config: &ActivationConfig, call_fn: F) -> Result<T, E>where E: Display, F: FnMut, Fut: FutureExecute an async operation with activation-aware retries.
call_fn receives the 0-indexed attempt number and returns Result<T, E>.
Errors whose Display output matches [ActivationConfig::is_retriable_error]
are retried with exponential backoff; all other errors are returned immediately.
Returns the first Ok, or the last Err when retries are exhausted.