Skip to main content

PullWorkerOptions

Struct PullWorkerOptions 

Source
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

Source

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.

Source

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.

Source

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);
Source

pub fn idle_streams_per_queue(self, value: usize) -> Self

👎Deprecated:

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PullWorkerOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PullWorkerOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more