Skip to main content

WorkerOptions

Struct WorkerOptions 

Source
pub struct WorkerOptions { /* private fields */ }
Expand description

Configures a pull crate::Worker and its outbound Dex connection.

Defaults connect to Dex at 127.0.0.1:8801, use PullWorkerOptions::default, and allow two minutes for Attribute-index synchronization. Workers need only an outbound connection. Changed in 1.25.0: every Worker uses pull mode; no listener or Worker target is configured.

Implementations§

Source§

impl WorkerOptions

Source

pub fn new() -> Self

Creates Worker options with local development defaults.

Source

pub fn flow_definition_paths<P: Into<PathBuf>>( self, value: impl IntoIterator<Item = P>, ) -> Self

Sets the Flow Definition Graph files that the Worker uploads to the Dex Server at start.

Dex Web draws each Flow type’s graph from the uploaded document. Generate the files with dexcli visualize. Each path must exist and be readable. An explicitly listed file must be a Flow Definition Graph 2.x: a UTF-8 JSON object whose schemaVersion starts with 2. and whose flow.name is a non-empty string; its extension is not checked. A directory is read recursively for files whose extension is .json in any case; a file there that is not a Flow Definition Graph 2.x is skipped with an info log, so a directory may hold other JSON files.

The Flow type of a file is its flow.name. Its generation time is its top-level generatedAt, which must be strict RFC 3339 such as 2026-11-01T00:00:00Z, or the file modification time when that is missing. Every generation time is truncated to whole milliseconds.

crate::Worker::try_new reads the files and returns crate::SdkError::FlowDefinition for a missing or unreadable path, an invalid explicit file, an invalid generatedAt, or a Flow type configured twice. crate::Worker::start uploads only documents for Flow types that the Registry registers, after protocol negotiation and Attribute-index synchronization and before it opens task streams, and sends nothing when none is left. An absolute top-level source.path, including a Windows drive or UNC path, is replaced by a path relative to the working directory, or by the file name when the file is elsewhere or the working directory is unknown. Requests hold at most 256 documents and 16 MiB of content and share one Self::attribute_index_sync_timeout deadline. crate::Worker::stop cancels an upload in progress. An upload failure, including an older Server without upload support, is logged as a warning; the Worker still starts. The default is no paths. Each call replaces the previous paths.

Since 1.45.0.

use dex_sdk::WorkerOptions;
let options = WorkerOptions::new()
    .server_address("dex:8801")
    .flow_definition_paths(["flow-definitions"]);
Source

pub fn flow_definitions( self, value: impl IntoIterator<Item = FlowDefinitionDocument>, ) -> Self

Sets in-memory Flow Definition Graph documents that the Worker uploads at start.

Use this when the application builds documents itself, for example from a template with a fixed generation time. Uploading, filtering to registered Flow types, the source.path rewrite, and failure handling work as for Self::flow_definition_paths. A Flow type may come from only one document across both settings. The default is no documents. Each call replaces the previous documents. crate::Worker::try_new returns crate::SdkError::FlowDefinition when a document is not a UTF-8 JSON object whose schemaVersion starts with 2., its flow.name differs from its Flow type, or two sources share a Flow type. See FlowDefinitionDocument for an example.

Since 1.45.0.

Source

pub fn server_address(self, value: impl Into<String>) -> Self

Sets the Dex FlowService address used by the Worker.

With TLS, accepts host:port, dns:///host:port, or dns://authority/host:port.

Source

pub fn flow_service_tls(self, value: FlowServiceTlsOptions) -> Self

Enables TLS for every outbound Worker FlowService connection.

Omitted by default, preserving plaintext gRPC. Takes ownership of value and returns these options with TLS enabled. crate::Worker::try_new validates the address, additional roots, and server name, returning crate::SdkError::InvalidArgument for invalid input. See FlowServiceTlsOptions for defaults and a complete example.

Source

pub fn credential(self, value: Arc<dyn Credential>) -> Self

Sends a bearer token on FlowService calls and pull Worker task streams.

The default sends no authorization metadata. The credential may be called concurrently; errors fail calls locally. Pull streams evaluate it at opening and again on reconnect. Enable Self::flow_service_tls to protect the token on the network.

Source

pub fn pull(self, value: PullWorkerOptions) -> Self

Configures pull capacity, queue registration, and graceful shutdown.

Every Worker uses pull; this builder overrides PullWorkerOptions::default. Takes ownership of value and returns these Worker options with its settings applied. crate::Worker::try_new validates capacity, identity, and timeout settings. See PullWorkerOptions for defaults and a complete Worker and Client example.

Source

pub fn attribute_index_sync_timeout(self, value: Duration) -> Self

Sets the startup Indexed Attribute synchronization deadline.

The default is two minutes. Worker::try_new rejects Duration::ZERO.

Trait Implementations§

Source§

impl Clone for WorkerOptions

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 WorkerOptions

Source§

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

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

impl Default for WorkerOptions

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