ff_sdk/config.rs
1use ff_core::backend::BackendConfig;
2use ff_core::types::{LaneId, Namespace, WorkerId, WorkerInstanceId};
3
4/// Configuration for a FlowFabric worker.
5///
6/// **RFC-012 Stage 1c tranche 1.** Valkey-specific connection
7/// parameters (`host`, `port`, `tls`, `cluster`) moved to the nested
8/// [`BackendConfig`] field, which also carries
9/// [`BackendTimeouts`](ff_core::backend::BackendTimeouts) and
10/// [`BackendRetry`](ff_core::backend::BackendRetry) policy. Build one
11/// with [`BackendConfig::valkey`] for the common standalone case; for
12/// TLS / cluster / tuned retry, construct the
13/// [`ValkeyConnection`](ff_core::backend::ValkeyConnection) and
14/// [`BackendConfig`] fields directly.
15///
16/// Worker-policy fields (`lease_ttl_ms`, `claim_poll_interval_ms`,
17/// capability set, lane list, identity) stay on `WorkerConfig` —
18/// those are orthogonal to the storage backend choice.
19///
20/// `WorkerConfig::new` was removed in this stage (pre-1.0 clean
21/// break); construct via struct literal.
22pub struct WorkerConfig {
23 /// Backend connection + shared timeouts / retry policy.
24 pub backend: BackendConfig,
25 /// Logical worker identity (e.g., "gpu-worker-pool-1").
26 pub worker_id: WorkerId,
27 /// Concrete worker process/runtime instance identity (e.g., container ID).
28 pub worker_instance_id: WorkerInstanceId,
29 /// Namespace this worker operates in.
30 pub namespace: Namespace,
31 /// Lanes this worker claims work from.
32 pub lanes: Vec<LaneId>,
33 /// Capabilities this worker advertises for routing.
34 pub capabilities: Vec<String>,
35 /// Lease TTL in milliseconds. Default: 30,000 (30s).
36 pub lease_ttl_ms: u64,
37 /// Interval between claim attempts when idle, in milliseconds. Default: 1,000 (1s).
38 pub claim_poll_interval_ms: u64,
39 /// Maximum concurrent tasks. Default: 1.
40 pub max_concurrent_tasks: usize,
41}
42
43impl WorkerConfig {
44 /// Lease renewal interval: TTL / 3 (renew at 1/3 of TTL, leaving 2/3 margin).
45 pub fn renewal_interval_ms(&self) -> u64 {
46 self.lease_ttl_ms / 3
47 }
48}