Skip to main content

WorkerOptions

Struct WorkerOptions 

Source
#[non_exhaustive]
pub struct WorkerOptions {
Show 18 fields pub task_queue: String, pub deployment_options: WorkerDeploymentOptions, pub client_identity_override: Option<String>, pub max_cached_workflows: usize, pub tuner: Arc<dyn WorkerTuner + Send + Sync>, pub workflow_task_poller_behavior: PollerBehavior, pub nonsticky_to_sticky_poll_ratio: f32, pub activity_task_poller_behavior: PollerBehavior, pub nexus_task_poller_behavior: PollerBehavior, pub task_types: WorkerTaskTypes, pub sticky_queue_schedule_to_start_timeout: Duration, pub max_heartbeat_throttle_interval: Duration, pub default_heartbeat_throttle_interval: Duration, pub max_task_queue_activities_per_second: Option<f64>, pub max_worker_activities_per_second: Option<f64>, pub workflow_failure_errors: HashSet<WorkflowErrorType>, pub workflow_types_to_failure_errors: HashMap<String, HashSet<WorkflowErrorType>>, pub graceful_shutdown_period: Option<Duration>, /* private fields */
}
Expand description

Contains options for configuring a worker.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§task_queue: String

What task queue will this worker poll from? This task queue name will be used for both workflow and activity polling.

§deployment_options: WorkerDeploymentOptions

Set the deployment options for this worker. Defaults to a hash of the currently running executable.

§client_identity_override: Option<String>

A human-readable string that can identify this worker. Using something like sdk version and host name is a good default. If set, overrides the identity set (if any) on the client used by this worker.

§max_cached_workflows: usize

If set nonzero, workflows will be cached and sticky task queues will be used, meaning that history updates are applied incrementally to suspended instances of workflow execution. Workflows are evicted according to a least-recently-used policy once the cache maximum is reached. Workflows may also be explicitly evicted at any time, or as a result of errors or failures.

§tuner: Arc<dyn WorkerTuner + Send + Sync>

Set a crate::WorkerTuner for this worker, which controls how many slots are available for the different kinds of tasks.

§workflow_task_poller_behavior: PollerBehavior

Controls how polling for Workflow tasks will happen on this worker’s task queue. See also WorkerConfig::nonsticky_to_sticky_poll_ratio. If using SimpleMaximum, Must be at least 2 when max_cached_workflows > 0, or is an error.

§nonsticky_to_sticky_poll_ratio: f32

Only applies when using PollerBehavior::SimpleMaximum

(max workflow task polls * this number) = the number of max pollers that will be allowed for the nonsticky queue when sticky tasks are enabled. If both defaults are used, the sticky queue will allow 4 max pollers while the nonsticky queue will allow one. The minimum for either poller is 1, so if the maximum allowed is 1 and sticky queues are enabled, there will be 2 concurrent polls.

§activity_task_poller_behavior: PollerBehavior

Controls how polling for Activity tasks will happen on this worker’s task queue.

§nexus_task_poller_behavior: PollerBehavior

Controls how polling for Nexus tasks will happen on this worker’s task queue.

§task_types: WorkerTaskTypes

Specifies which task types this worker will poll for.

Note: At least one task type must be specified or the worker will fail validation.

§sticky_queue_schedule_to_start_timeout: Duration

How long a workflow task is allowed to sit on the sticky queue before it is timed out and moved to the non-sticky queue where it may be picked up by any worker.

§max_heartbeat_throttle_interval: Duration

Longest interval for throttling activity heartbeats

§default_heartbeat_throttle_interval: Duration

Default interval for throttling activity heartbeats in case ActivityOptions.heartbeat_timeout is unset. When the timeout is set in the ActivityOptions, throttling is set to heartbeat_timeout * 0.8.

§max_task_queue_activities_per_second: Option<f64>

Sets the maximum number of activities per second the task queue will dispatch, controlled server-side. Note that this only takes effect upon an activity poll request. If multiple workers on the same queue have different values set, they will thrash with the last poller winning.

Setting this to a nonzero value will also disable eager activity execution.

§max_worker_activities_per_second: Option<f64>

Limits the number of activities per second that this worker will process. The worker will not poll for new activities if by doing so it might receive and execute an activity which would cause it to exceed this limit. Negative, zero, or NaN values will cause building the options to fail.

§workflow_failure_errors: HashSet<WorkflowErrorType>

Any error types listed here will cause any workflow being processed by this worker to fail, rather than simply failing the workflow task.

§workflow_types_to_failure_errors: HashMap<String, HashSet<WorkflowErrorType>>

Like WorkerConfig::workflow_failure_errors, but specific to certain workflow types (the map key).

§graceful_shutdown_period: Option<Duration>

If set, the worker will issue cancels for all outstanding activities and nexus operations after shutdown has been initiated and this amount of time has elapsed.

Implementations§

Source§

impl WorkerOptions

Source

pub fn new(task_queue: impl Into<String>) -> WorkerOptionsBuilder

Create an instance of WorkerOptions using the builder syntax

Source§

impl WorkerOptions

Source

pub fn register_activities<AI: ActivityImplementer>( &mut self, instance: AI, ) -> &mut Self

Registers all activities on an activity implementer.

Source

pub fn register_activity<AD>( &mut self, instance: Arc<AD::Implementer>, ) -> &mut Self
where AD: ActivityDefinition + ExecutableActivity, AD::Output: Send + Sync,

Registers a specific activitiy.

Source

pub fn activities(&self) -> ActivityDefinitions

Returns all the registered activities by cloning the current set.

Source

pub fn register_workflow<WI: WorkflowImplementer>(&mut self) -> &mut Self

Registers all workflows on a workflow implementer.

Source

pub fn register_workflow_with_factory<W, F>(&mut self, factory: F) -> &mut Self
where W: WorkflowImplementation, <W::Run as WorkflowDefinition>::Input: Send, F: Fn() -> W + Send + Sync + 'static,

Register a workflow with a custom factory for instance creation.

§Warning: Advanced Usage

See WorkerOptionsBuilder::register_workflow_with_factory for more.

Source

pub fn workflows(&self) -> WorkflowDefinitions

Returns all the registered workflows by cloning the current set.

Trait Implementations§

Source§

impl Clone for WorkerOptions

Source§

fn clone(&self) -> WorkerOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. 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> Any for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> AnySync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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: 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: 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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
Source§

impl<T> ErasedDestructor for T
where T: 'static,