pub struct RuntimeOptions {
pub dispatcher_min_poll_interval: Duration,
pub dispatcher_long_poll_timeout: Duration,
pub orchestration_concurrency: usize,
pub worker_concurrency: usize,
pub orchestrator_lock_timeout: Duration,
pub orchestrator_lock_renewal_buffer: Duration,
pub worker_lock_timeout: Duration,
pub worker_lock_renewal_buffer: Duration,
pub observability: ObservabilityConfig,
pub unregistered_backoff: UnregisteredBackoffConfig,
pub max_attempts: u32,
pub activity_cancellation_grace_period: Duration,
}Expand description
Configuration options for the Runtime.
§Example
let options = RuntimeOptions {
orchestration_concurrency: 4,
worker_concurrency: 8,
dispatcher_min_poll_interval: Duration::from_millis(25), // Polling backoff when queues idle
dispatcher_long_poll_timeout: Duration::from_secs(30), // Long polling timeout
orchestrator_lock_timeout: Duration::from_secs(10), // Orchestration turns retry after 10s
worker_lock_timeout: Duration::from_secs(300), // Activities retry after 5 minutes
worker_lock_renewal_buffer: Duration::from_secs(30), // Renew worker locks 30s early
observability: ObservabilityConfig {
log_format: LogFormat::Compact,
log_level: "info".to_string(),
..Default::default()
},
..Default::default()
};Fields§
§dispatcher_min_poll_interval: DurationMinimum polling cycle duration when idle.
If a provider returns ‘None’ (no work) faster than this duration, the dispatcher will sleep for the remainder of the time. This prevents hot loops for providers that do not support long polling or return early.
Default: 100ms (10 Hz)
dispatcher_long_poll_timeout: DurationMaximum time to wait for work inside the provider (Long Polling).
Only used if the provider supports long polling.
Default: 30 seconds
orchestration_concurrency: usizeNumber of concurrent orchestration workers. Each worker can process one orchestration turn at a time. Higher values = more parallel orchestration execution. Default: 2
worker_concurrency: usizeNumber of concurrent worker dispatchers. Each worker can execute one activity at a time. Higher values = more parallel activity execution. Default: 2
orchestrator_lock_timeout: DurationLock timeout for orchestrator queue items. When an orchestration message is dequeued, it’s locked for this duration. Orchestration turns are typically fast (milliseconds), so a shorter timeout is appropriate. If processing doesn’t complete within this time, the lock expires and the message is retried. Default: 5 seconds
orchestrator_lock_renewal_buffer: DurationBuffer time before orchestration lock expiration to trigger renewal.
Lock renewal strategy:
- If
orchestrator_lock_timeout≥ 15s: renew at (timeout - orchestrator_lock_renewal_buffer) - If
orchestrator_lock_timeout< 15s: renew at 0.5 × timeout (buffer ignored)
Default: 2 seconds
worker_lock_timeout: DurationLock timeout for worker queue items (activities). When an activity is dequeued, it’s locked for this duration. Activities can be long-running (minutes), so a longer timeout is appropriate. If processing doesn’t complete within this time, the lock expires and the activity is retried. Higher values = more tolerance for long-running activities. Lower values = faster retry on failures, but may timeout legitimate work. Default: 30 seconds
worker_lock_renewal_buffer: DurationBuffer time before lock expiration to trigger renewal.
Lock renewal strategy:
- If
worker_lock_timeout≥ 15s: renew at (timeout - worker_lock_renewal_buffer) - If
worker_lock_timeout< 15s: renew at 0.5 × timeout (buffer ignored)
Example with default values (timeout=30s, buffer=5s):
- Initial lock: expires at T+30s
- First renewal: at T+25s (30-5), extends to T+55s
- Second renewal: at T+50s (55-5), extends to T+80s
Example with short timeout (timeout=10s, buffer ignored):
- Initial lock: expires at T+10s
- First renewal: at T+5s (10*0.5), extends to T+15s
- Second renewal: at T+10s (15*0.5), extends to T+20s
Default: 5 seconds
observability: ObservabilityConfigObservability configuration for metrics and logging.
Requires the observability feature flag for full functionality.
Default: Disabled with basic logging
unregistered_backoff: UnregisteredBackoffConfigConfiguration for backoff when encountering unregistered orchestrations/activities.
During rolling deployments, work items for unregistered handlers are abandoned with exponential backoff instead of immediately failing. This allows the runtime to wait for the handler to be registered on upgraded nodes.
Default: 1s base delay, 60s max delay
max_attempts: u32Maximum fetch attempts before a message is considered poison.
After this many fetch attempts, the runtime will immediately fail the orchestration/activity with a Poison error instead of processing.
Default: 10
activity_cancellation_grace_period: DurationGrace period for activity cancellation.
When an orchestration reaches a terminal state, in-flight activities are notified via their cancellation token. This setting controls how long to wait for activities to complete gracefully before aborting the activity task to free worker capacity.
After this grace period, if the activity has not completed:
- The activity task is aborted (
JoinHandle::abort()) - The worker queue message is dropped without notifying the orchestrator
- A warning is logged
Note: Child tasks/threads spawned by the activity that do not observe the cancellation token may outlive the abort (user responsibility).
Default: 10 seconds
Trait Implementations§
Source§impl Clone for RuntimeOptions
impl Clone for RuntimeOptions
Source§fn clone(&self) -> RuntimeOptions
fn clone(&self) -> RuntimeOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more