#[non_exhaustive]pub struct WorkerOptions {Show 22 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: Option<PollerBehavior>,
pub nonsticky_to_sticky_poll_ratio: f32,
pub activity_task_poller_behavior: Option<PollerBehavior>,
pub nexus_task_poller_behavior: Option<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 max_eager_activity_reservations_per_workflow_task: usize,
pub workflow_failure_errors: HashSet<WorkflowErrorType>,
pub workflow_types_to_failure_errors: HashMap<String, HashSet<WorkflowErrorType>>,
pub graceful_shutdown_period: Option<Duration>,
pub detect_nondeterministic_futures: bool,
pub disable_payload_error_limit: bool,
pub patch_activation_callback: Option<PatchActivationCallback>,
/* private fields */
}Expand description
Contains options for configuring a worker.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.task_queue: StringWhat task queue will this worker poll from? This task queue name will be used for both workflow and activity polling.
deployment_options: WorkerDeploymentOptionsSet 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. If set, overrides the identity on
the client used by this worker. If unset and the client has no identity, defaults to
{pid}@{hostname}.
max_cached_workflows: usizeIf 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: Option<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.
If left unset, the worker uses SimpleMaximum(5) and becomes eligible for automatic
enrollment into poller autoscaling when the namespace advertises support for it.
nonsticky_to_sticky_poll_ratio: f32Only 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: Option<PollerBehavior>Controls how polling for Activity tasks will happen on this worker’s task queue.
If left unset, the worker uses SimpleMaximum(5) and becomes eligible for automatic
enrollment into poller autoscaling when the namespace advertises support for it.
nexus_task_poller_behavior: Option<PollerBehavior>Controls how polling for Nexus tasks will happen on this worker’s task queue.
If left unset, the worker uses SimpleMaximum(5) and becomes eligible for automatic
enrollment into poller autoscaling when the namespace advertises support for it.
task_types: WorkerTaskTypesSpecifies 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: DurationHow 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: DurationLongest interval for throttling activity heartbeats
default_heartbeat_throttle_interval: DurationDefault 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.
max_eager_activity_reservations_per_workflow_task: usizeMaximum number of activity slots that may be reserved for eager execution when completing a workflow task. The default is 3. Setting this to zero disables eager activity execution.
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.
detect_nondeterministic_futures: boolDetect nondeterministic async usage in workflow code. When enabled (the default), workflows that use external async operations (tokio timers, IO, spawned threads, raw tokio::sync channels, etc.) will have their tasks failed with a descriptive error.
disable_payload_error_limit: boolIf set true, the worker will not proactively fail workflow/activity tasks whose payloads exceed the namespace error limits; oversized payloads are sent to server, which enforces the limit. Defaults to false. NOTE: Experimental
patch_activation_callback: Option<PatchActivationCallback>Experimental callback that decides whether the first non-replay call to
SyncWorkflowContext::patched for a patch ID should activate that patch.
The callback receives an immutable workflow information snapshot and patch ID. Returning
true records the patch marker; returning false leaves the patch inactive for the
workflow run. For registered WASM workflow components, the callback remains on the worker
host and is invoked through the workflow component’s synchronous host interface.
Implementations§
Source§impl WorkerOptions
impl WorkerOptions
Sourcepub fn new(task_queue: impl Into<String>) -> WorkerOptionsBuilder
pub fn new(task_queue: impl Into<String>) -> WorkerOptionsBuilder
Create an instance of WorkerOptions using the builder syntax
Source§impl WorkerOptions
impl WorkerOptions
Sourcepub fn register_activities<AI: ActivityImplementer>(
&mut self,
instance: AI,
) -> &mut Self
pub fn register_activities<AI: ActivityImplementer>( &mut self, instance: AI, ) -> &mut Self
Registers all activities on an activity implementer.
Sourcepub fn register_activity<AD>(
&mut self,
instance: Arc<AD::Implementer>,
) -> &mut Self
pub fn register_activity<AD>( &mut self, instance: Arc<AD::Implementer>, ) -> &mut Self
Registers a specific activitiy.
Sourcepub fn activities(&self) -> ActivityDefinitions
pub fn activities(&self) -> ActivityDefinitions
Returns all the registered activities by cloning the current set.
Sourcepub fn register_workflow<W>(
&mut self,
) -> Result<&mut Self, WorkflowRegistrationError>
pub fn register_workflow<W>( &mut self, ) -> Result<&mut Self, WorkflowRegistrationError>
Registers all workflows on a workflow implementer.
Sourcepub fn register_workflow_with_factory<W, F>(
&mut self,
factory: F,
) -> Result<&mut Self, WorkflowRegistrationError>where
W: WorkflowImplementation,
<W::Run as WorkflowDefinition>::Input: Send,
F: Fn() -> W + Send + Sync + 'static,
pub fn register_workflow_with_factory<W, F>(
&mut self,
factory: F,
) -> Result<&mut Self, WorkflowRegistrationError>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.
Sourcepub fn register_workflow_interceptors(
&mut self,
constructors: Vec<WorkflowInterceptorConstructor>,
) -> &mut Self
pub fn register_workflow_interceptors( &mut self, constructors: Vec<WorkflowInterceptorConstructor>, ) -> &mut Self
Set the ordered constructors used to create workflow interceptors for each workflow instance.
This replaces any previously configured workflow interceptor constructors.
Sourcepub fn workflows(&self) -> WorkflowDefinitions
pub fn workflows(&self) -> WorkflowDefinitions
Returns all the registered workflows by cloning the current set.
Trait Implementations§
Source§impl Clone for WorkerOptions
impl Clone for WorkerOptions
Source§fn clone(&self) -> WorkerOptions
fn clone(&self) -> WorkerOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for WorkerOptions
impl !UnwindSafe for WorkerOptions
impl Freeze for WorkerOptions
impl Send for WorkerOptions
impl Sync for WorkerOptions
impl Unpin for WorkerOptions
impl UnsafeUnpin for WorkerOptions
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§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