pub struct PullWorkerOptions { /* private fields */ }Expand description
Configures outbound polling for a Worker.
Pass this to WorkerOptions::pull. The Worker polls its sticky queue and each registered
Flow type through exactly max_concurrent_tasks long-lived slot streams. An omitted task limit
uses the CPU count. An omitted drain timeout uses 30 seconds.
Changed in 1.35.0: each execution slot owns one stream, replacing per-queue idle streams. Start requires protocol 4 (server-zd newer than v0.1.16); upgrade the Server before the SDK.
use std::sync::Arc;
use dex_sdk::{BlobCache, BlobCacheConfig, Client, ClientOptions, PullWorkerOptions,
Registry, Worker, WorkerOptions};
let cache = Arc::new(BlobCache::open(BlobCacheConfig::new(
"/tmp/dex-pull-blobs", 64 * 1024 * 1024, 0,
)?)?);
let registry = Registry::new();
let worker = Worker::try_new(registry.clone(), cache.clone(),
WorkerOptions::new().pull(PullWorkerOptions::new().max_concurrent_tasks(8)))?;
let client = Client::try_new(registry, cache,
ClientOptions::new())?;
// Run worker.start() on a dedicated thread; call worker.stop() during shutdown.Implementations§
Source§impl PullWorkerOptions
impl PullWorkerOptions
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates pull options with CPU-count slot concurrency and a 30-second drain.
The app Worker ID is generated from process identity and eight random base32 characters.
Sourcepub fn max_concurrent_tasks(self, value: usize) -> Self
pub fn max_concurrent_tasks(self, value: usize) -> Self
Sets the maximum number of concurrent Step and RPC handlers.
The default is the available CPU count. Zero returns crate::SdkError::FlowDefinition
from crate::Worker::try_new. Each slot owns one long-lived poll stream and executes
every task assigned to it. Changed in 1.35.0: crate::Worker::start fails if this value
exceeds the Server’s reported per-Worker limit, configured by matching.maxConcurrentTasksCap.
Sourcepub fn reserved_rpc_tasks(self, value: usize) -> Self
pub fn reserved_rpc_tasks(self, value: usize) -> Self
Reserves slots that accept only RPCs, protecting RPC latency from long-running Steps.
Changed in 1.23.0: reserved RPC capacity remains available under a Step backlog. Changed in 1.35.0: reservations select RPC-only streams instead of declining assigned Steps; the Worker executes every assignment.
The default reserves one slot when resolved concurrency is at least two, otherwise zero.
The remaining slots accept Steps and RPCs. The Server selects eligible slots; the Worker
never declines a Step for capacity. Set zero to allow Steps on every slot. A one-slot
Worker with no explicit reservation warns that RPCs may wait behind Steps.
Readiness requires a registered Step-and-RPC slot and, with a reservation, an RPC-only slot.
value must be less than resolved max_concurrent_tasks; otherwise
crate::Worker::try_new returns crate::SdkError::FlowDefinition.
Returns these options with the reservation applied.
use dex_sdk::PullWorkerOptions;
let pull = PullWorkerOptions::new().max_concurrent_tasks(8).reserved_rpc_tasks(2);Sourcepub fn idle_streams_per_queue(self, value: usize) -> Self
👎Deprecated: one long-lived stream per execution slot; this setting has no effect
pub fn idle_streams_per_queue(self, value: usize) -> Self
one long-lived stream per execution slot; this setting has no effect
Retains the former per-queue idle-stream setting for source compatibility.
Changed in 1.35.0: this setting became a compatibility-only no-op.
Deprecated: value is accepted, including zero, and has no effect. Every execution slot
now owns exactly one long-lived stream. Use Self::max_concurrent_tasks to select the
total stream count. Returns these options with the compatibility value retained.
Sourcepub fn app_worker_id(self, value: impl Into<String>) -> Self
pub fn app_worker_id(self, value: impl Into<String>) -> Self
Overrides the process Worker ID used for sticky routing.
Use a new ID after each process restart. It must contain 1–63 ASCII letters, digits,
dots, underscores, or hyphens and must differ from every registered Flow type.
Invalid values return crate::SdkError::FlowDefinition from crate::Worker::try_new.
If omitted, the Worker generates a fresh ID during construction.
Sourcepub fn stop_on_permanent_stream_rejection(self, value: bool) -> Self
pub fn stop_on_permanent_stream_rejection(self, value: bool) -> Self
Stops when a permanent rejection leaves a required slot kind without any registered stream.
Defaults to false, retrying indefinitely. When enabled, crate::Worker::start drains
within the configured timeout, cancels remaining handlers, and waits for their return.
It returns a service error exposing crate::SdkError::pull_registration_error before or after initial readiness.
Calling crate::Worker::stop afterward remains safe.
Sourcepub fn stop_drain_timeout(self, value: Duration) -> Self
pub fn stop_drain_timeout(self, value: Duration) -> Self
Bounds graceful drain before active handlers are cancelled.
The default is 30 seconds. Zero returns crate::SdkError::FlowDefinition from
crate::Worker::try_new.
A busy server-directed Reconnect uses this duration to wait for server EOF after the final frame.
During Stop, idle streams half-close immediately. Busy streams finish and send their final
output before half-closing. Later task frames are dropped without invoking handlers, and
half-closed streams keep reading until the Server ends them or the drain deadline expires.
At the deadline, a stream with a running handler is reset instead of half-closed.
crate::Worker::start waits for cancelled handlers to return before it exits.
Every other stream still waiting for the Server to end it is reset at the deadline.
A stream whose last final output Dex has not yet acknowledged with a new task waits up to
five seconds past this deadline for the Server to end it, then is reset.
Stop can therefore return up to five seconds after this deadline.
Trait Implementations§
Source§impl Clone for PullWorkerOptions
impl Clone for PullWorkerOptions
Source§impl Debug for PullWorkerOptions
impl Debug for PullWorkerOptions
Auto Trait Implementations§
impl Forget for PullWorkerOptions
impl Freeze for PullWorkerOptions
impl RefUnwindSafe for PullWorkerOptions
impl Send for PullWorkerOptions
impl Sync for PullWorkerOptions
impl Unpin for PullWorkerOptions
impl UnsafeUnpin for PullWorkerOptions
impl UnwindSafe for PullWorkerOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request