pub struct WorkerOptionsBuilder<S: State = Empty> { /* private fields */ }Expand description
Use builder syntax to set the inputs and finish with build().
Implementations§
Source§impl<S: State> WorkerOptionsBuilder<S>
impl<S: State> WorkerOptionsBuilder<S>
Sourcepub fn build(self) -> WorkerOptionswhere
S: IsComplete,
pub fn build(self) -> WorkerOptionswhere
S: IsComplete,
Finish building and return the requested object
Sourcepub fn deployment_options(
self,
value: WorkerDeploymentOptions,
) -> WorkerOptionsBuilder<SetDeploymentOptions<S>>where
S::DeploymentOptions: IsUnset,
pub fn deployment_options(
self,
value: WorkerDeploymentOptions,
) -> WorkerOptionsBuilder<SetDeploymentOptions<S>>where
S::DeploymentOptions: IsUnset,
Sourcepub fn maybe_deployment_options(
self,
value: Option<WorkerDeploymentOptions>,
) -> WorkerOptionsBuilder<SetDeploymentOptions<S>>where
S::DeploymentOptions: IsUnset,
pub fn maybe_deployment_options(
self,
value: Option<WorkerDeploymentOptions>,
) -> WorkerOptionsBuilder<SetDeploymentOptions<S>>where
S::DeploymentOptions: IsUnset,
Sourcepub fn client_identity_override(
self,
value: impl Into<String>,
) -> WorkerOptionsBuilder<SetClientIdentityOverride<S>>where
S::ClientIdentityOverride: IsUnset,
pub fn client_identity_override(
self,
value: impl Into<String>,
) -> WorkerOptionsBuilder<SetClientIdentityOverride<S>>where
S::ClientIdentityOverride: IsUnset,
Sourcepub fn maybe_client_identity_override(
self,
value: Option<impl Into<String>>,
) -> WorkerOptionsBuilder<SetClientIdentityOverride<S>>where
S::ClientIdentityOverride: IsUnset,
pub fn maybe_client_identity_override(
self,
value: Option<impl Into<String>>,
) -> WorkerOptionsBuilder<SetClientIdentityOverride<S>>where
S::ClientIdentityOverride: IsUnset,
Sourcepub fn max_cached_workflows(
self,
value: usize,
) -> WorkerOptionsBuilder<SetMaxCachedWorkflows<S>>where
S::MaxCachedWorkflows: IsUnset,
pub fn max_cached_workflows(
self,
value: usize,
) -> WorkerOptionsBuilder<SetMaxCachedWorkflows<S>>where
S::MaxCachedWorkflows: IsUnset,
Optional (Some / Option setters). Default: 1000.
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.
Sourcepub fn maybe_max_cached_workflows(
self,
value: Option<usize>,
) -> WorkerOptionsBuilder<SetMaxCachedWorkflows<S>>where
S::MaxCachedWorkflows: IsUnset,
pub fn maybe_max_cached_workflows(
self,
value: Option<usize>,
) -> WorkerOptionsBuilder<SetMaxCachedWorkflows<S>>where
S::MaxCachedWorkflows: IsUnset,
Optional (Some / Option setters). Default: 1000.
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.
Sourcepub fn tuner(
self,
value: Arc<dyn WorkerTuner + Send + Sync>,
) -> WorkerOptionsBuilder<SetTuner<S>>
pub fn tuner( self, value: Arc<dyn WorkerTuner + Send + Sync>, ) -> WorkerOptionsBuilder<SetTuner<S>>
Optional (Some / Option setters). Default: Arc::new(TunerBuilder::default().build()).
Set a crate::WorkerTuner for this worker, which controls how many slots are available for the different kinds of tasks.
Sourcepub fn maybe_tuner(
self,
value: Option<Arc<dyn WorkerTuner + Send + Sync>>,
) -> WorkerOptionsBuilder<SetTuner<S>>
pub fn maybe_tuner( self, value: Option<Arc<dyn WorkerTuner + Send + Sync>>, ) -> WorkerOptionsBuilder<SetTuner<S>>
Optional (Some / Option setters). Default: Arc::new(TunerBuilder::default().build()).
Set a crate::WorkerTuner for this worker, which controls how many slots are available for the different kinds of tasks.
Sourcepub fn workflow_task_poller_behavior(
self,
value: PollerBehavior,
) -> WorkerOptionsBuilder<SetWorkflowTaskPollerBehavior<S>>where
S::WorkflowTaskPollerBehavior: IsUnset,
pub fn workflow_task_poller_behavior(
self,
value: PollerBehavior,
) -> WorkerOptionsBuilder<SetWorkflowTaskPollerBehavior<S>>where
S::WorkflowTaskPollerBehavior: IsUnset,
Optional (Some / Option setters). Default: PollerBehavior::SimpleMaximum(5).
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.
Sourcepub fn maybe_workflow_task_poller_behavior(
self,
value: Option<PollerBehavior>,
) -> WorkerOptionsBuilder<SetWorkflowTaskPollerBehavior<S>>where
S::WorkflowTaskPollerBehavior: IsUnset,
pub fn maybe_workflow_task_poller_behavior(
self,
value: Option<PollerBehavior>,
) -> WorkerOptionsBuilder<SetWorkflowTaskPollerBehavior<S>>where
S::WorkflowTaskPollerBehavior: IsUnset,
Optional (Some / Option setters). Default: PollerBehavior::SimpleMaximum(5).
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.
Sourcepub fn nonsticky_to_sticky_poll_ratio(
self,
value: f32,
) -> WorkerOptionsBuilder<SetNonstickyToStickyPollRatio<S>>where
S::NonstickyToStickyPollRatio: IsUnset,
pub fn nonsticky_to_sticky_poll_ratio(
self,
value: f32,
) -> WorkerOptionsBuilder<SetNonstickyToStickyPollRatio<S>>where
S::NonstickyToStickyPollRatio: IsUnset,
Optional (Some / Option setters). Default: 0.2.
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.
Sourcepub fn maybe_nonsticky_to_sticky_poll_ratio(
self,
value: Option<f32>,
) -> WorkerOptionsBuilder<SetNonstickyToStickyPollRatio<S>>where
S::NonstickyToStickyPollRatio: IsUnset,
pub fn maybe_nonsticky_to_sticky_poll_ratio(
self,
value: Option<f32>,
) -> WorkerOptionsBuilder<SetNonstickyToStickyPollRatio<S>>where
S::NonstickyToStickyPollRatio: IsUnset,
Optional (Some / Option setters). Default: 0.2.
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.
Sourcepub fn activity_task_poller_behavior(
self,
value: PollerBehavior,
) -> WorkerOptionsBuilder<SetActivityTaskPollerBehavior<S>>where
S::ActivityTaskPollerBehavior: IsUnset,
pub fn activity_task_poller_behavior(
self,
value: PollerBehavior,
) -> WorkerOptionsBuilder<SetActivityTaskPollerBehavior<S>>where
S::ActivityTaskPollerBehavior: IsUnset,
Sourcepub fn maybe_activity_task_poller_behavior(
self,
value: Option<PollerBehavior>,
) -> WorkerOptionsBuilder<SetActivityTaskPollerBehavior<S>>where
S::ActivityTaskPollerBehavior: IsUnset,
pub fn maybe_activity_task_poller_behavior(
self,
value: Option<PollerBehavior>,
) -> WorkerOptionsBuilder<SetActivityTaskPollerBehavior<S>>where
S::ActivityTaskPollerBehavior: IsUnset,
Sourcepub fn nexus_task_poller_behavior(
self,
value: PollerBehavior,
) -> WorkerOptionsBuilder<SetNexusTaskPollerBehavior<S>>where
S::NexusTaskPollerBehavior: IsUnset,
pub fn nexus_task_poller_behavior(
self,
value: PollerBehavior,
) -> WorkerOptionsBuilder<SetNexusTaskPollerBehavior<S>>where
S::NexusTaskPollerBehavior: IsUnset,
Sourcepub fn maybe_nexus_task_poller_behavior(
self,
value: Option<PollerBehavior>,
) -> WorkerOptionsBuilder<SetNexusTaskPollerBehavior<S>>where
S::NexusTaskPollerBehavior: IsUnset,
pub fn maybe_nexus_task_poller_behavior(
self,
value: Option<PollerBehavior>,
) -> WorkerOptionsBuilder<SetNexusTaskPollerBehavior<S>>where
S::NexusTaskPollerBehavior: IsUnset,
Sourcepub fn task_types(
self,
value: WorkerTaskTypes,
) -> WorkerOptionsBuilder<SetTaskTypes<S>>
pub fn task_types( self, value: WorkerTaskTypes, ) -> WorkerOptionsBuilder<SetTaskTypes<S>>
Sourcepub fn maybe_task_types(
self,
value: Option<WorkerTaskTypes>,
) -> WorkerOptionsBuilder<SetTaskTypes<S>>
pub fn maybe_task_types( self, value: Option<WorkerTaskTypes>, ) -> WorkerOptionsBuilder<SetTaskTypes<S>>
Sourcepub fn sticky_queue_schedule_to_start_timeout(
self,
value: Duration,
) -> WorkerOptionsBuilder<SetStickyQueueScheduleToStartTimeout<S>>where
S::StickyQueueScheduleToStartTimeout: IsUnset,
pub fn sticky_queue_schedule_to_start_timeout(
self,
value: Duration,
) -> WorkerOptionsBuilder<SetStickyQueueScheduleToStartTimeout<S>>where
S::StickyQueueScheduleToStartTimeout: IsUnset,
Sourcepub fn maybe_sticky_queue_schedule_to_start_timeout(
self,
value: Option<Duration>,
) -> WorkerOptionsBuilder<SetStickyQueueScheduleToStartTimeout<S>>where
S::StickyQueueScheduleToStartTimeout: IsUnset,
pub fn maybe_sticky_queue_schedule_to_start_timeout(
self,
value: Option<Duration>,
) -> WorkerOptionsBuilder<SetStickyQueueScheduleToStartTimeout<S>>where
S::StickyQueueScheduleToStartTimeout: IsUnset,
Sourcepub fn max_heartbeat_throttle_interval(
self,
value: Duration,
) -> WorkerOptionsBuilder<SetMaxHeartbeatThrottleInterval<S>>where
S::MaxHeartbeatThrottleInterval: IsUnset,
pub fn max_heartbeat_throttle_interval(
self,
value: Duration,
) -> WorkerOptionsBuilder<SetMaxHeartbeatThrottleInterval<S>>where
S::MaxHeartbeatThrottleInterval: IsUnset,
Sourcepub fn maybe_max_heartbeat_throttle_interval(
self,
value: Option<Duration>,
) -> WorkerOptionsBuilder<SetMaxHeartbeatThrottleInterval<S>>where
S::MaxHeartbeatThrottleInterval: IsUnset,
pub fn maybe_max_heartbeat_throttle_interval(
self,
value: Option<Duration>,
) -> WorkerOptionsBuilder<SetMaxHeartbeatThrottleInterval<S>>where
S::MaxHeartbeatThrottleInterval: IsUnset,
Sourcepub fn default_heartbeat_throttle_interval(
self,
value: Duration,
) -> WorkerOptionsBuilder<SetDefaultHeartbeatThrottleInterval<S>>where
S::DefaultHeartbeatThrottleInterval: IsUnset,
pub fn default_heartbeat_throttle_interval(
self,
value: Duration,
) -> WorkerOptionsBuilder<SetDefaultHeartbeatThrottleInterval<S>>where
S::DefaultHeartbeatThrottleInterval: IsUnset,
Sourcepub fn maybe_default_heartbeat_throttle_interval(
self,
value: Option<Duration>,
) -> WorkerOptionsBuilder<SetDefaultHeartbeatThrottleInterval<S>>where
S::DefaultHeartbeatThrottleInterval: IsUnset,
pub fn maybe_default_heartbeat_throttle_interval(
self,
value: Option<Duration>,
) -> WorkerOptionsBuilder<SetDefaultHeartbeatThrottleInterval<S>>where
S::DefaultHeartbeatThrottleInterval: IsUnset,
Sourcepub fn max_task_queue_activities_per_second(
self,
value: f64,
) -> WorkerOptionsBuilder<SetMaxTaskQueueActivitiesPerSecond<S>>where
S::MaxTaskQueueActivitiesPerSecond: IsUnset,
pub fn max_task_queue_activities_per_second(
self,
value: f64,
) -> WorkerOptionsBuilder<SetMaxTaskQueueActivitiesPerSecond<S>>where
S::MaxTaskQueueActivitiesPerSecond: IsUnset,
Optional (Some / Option setters).
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.
Sourcepub fn maybe_max_task_queue_activities_per_second(
self,
value: Option<f64>,
) -> WorkerOptionsBuilder<SetMaxTaskQueueActivitiesPerSecond<S>>where
S::MaxTaskQueueActivitiesPerSecond: IsUnset,
pub fn maybe_max_task_queue_activities_per_second(
self,
value: Option<f64>,
) -> WorkerOptionsBuilder<SetMaxTaskQueueActivitiesPerSecond<S>>where
S::MaxTaskQueueActivitiesPerSecond: IsUnset,
Optional (Some / Option setters).
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.
Sourcepub fn max_worker_activities_per_second(
self,
value: f64,
) -> WorkerOptionsBuilder<SetMaxWorkerActivitiesPerSecond<S>>where
S::MaxWorkerActivitiesPerSecond: IsUnset,
pub fn max_worker_activities_per_second(
self,
value: f64,
) -> WorkerOptionsBuilder<SetMaxWorkerActivitiesPerSecond<S>>where
S::MaxWorkerActivitiesPerSecond: IsUnset,
Optional (Some / Option setters).
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.
Sourcepub fn maybe_max_worker_activities_per_second(
self,
value: Option<f64>,
) -> WorkerOptionsBuilder<SetMaxWorkerActivitiesPerSecond<S>>where
S::MaxWorkerActivitiesPerSecond: IsUnset,
pub fn maybe_max_worker_activities_per_second(
self,
value: Option<f64>,
) -> WorkerOptionsBuilder<SetMaxWorkerActivitiesPerSecond<S>>where
S::MaxWorkerActivitiesPerSecond: IsUnset,
Optional (Some / Option setters).
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.
Sourcepub fn workflow_failure_errors(
self,
value: HashSet<WorkflowErrorType>,
) -> WorkerOptionsBuilder<SetWorkflowFailureErrors<S>>where
S::WorkflowFailureErrors: IsUnset,
pub fn workflow_failure_errors(
self,
value: HashSet<WorkflowErrorType>,
) -> WorkerOptionsBuilder<SetWorkflowFailureErrors<S>>where
S::WorkflowFailureErrors: IsUnset,
Sourcepub fn maybe_workflow_failure_errors(
self,
value: Option<HashSet<WorkflowErrorType>>,
) -> WorkerOptionsBuilder<SetWorkflowFailureErrors<S>>where
S::WorkflowFailureErrors: IsUnset,
pub fn maybe_workflow_failure_errors(
self,
value: Option<HashSet<WorkflowErrorType>>,
) -> WorkerOptionsBuilder<SetWorkflowFailureErrors<S>>where
S::WorkflowFailureErrors: IsUnset,
Sourcepub fn workflow_types_to_failure_errors(
self,
value: HashMap<String, HashSet<WorkflowErrorType>>,
) -> WorkerOptionsBuilder<SetWorkflowTypesToFailureErrors<S>>where
S::WorkflowTypesToFailureErrors: IsUnset,
pub fn workflow_types_to_failure_errors(
self,
value: HashMap<String, HashSet<WorkflowErrorType>>,
) -> WorkerOptionsBuilder<SetWorkflowTypesToFailureErrors<S>>where
S::WorkflowTypesToFailureErrors: IsUnset,
Optional (Some / Option setters). Default: <HashMap<String, HashSet<WorkflowErrorType>> as Default>::default().
Like WorkerConfig::workflow_failure_errors, but specific to certain workflow types (the map key).
Sourcepub fn maybe_workflow_types_to_failure_errors(
self,
value: Option<HashMap<String, HashSet<WorkflowErrorType>>>,
) -> WorkerOptionsBuilder<SetWorkflowTypesToFailureErrors<S>>where
S::WorkflowTypesToFailureErrors: IsUnset,
pub fn maybe_workflow_types_to_failure_errors(
self,
value: Option<HashMap<String, HashSet<WorkflowErrorType>>>,
) -> WorkerOptionsBuilder<SetWorkflowTypesToFailureErrors<S>>where
S::WorkflowTypesToFailureErrors: IsUnset,
Optional (Some / Option setters). Default: <HashMap<String, HashSet<WorkflowErrorType>> as Default>::default().
Like WorkerConfig::workflow_failure_errors, but specific to certain workflow types (the map key).
Sourcepub fn graceful_shutdown_period(
self,
value: Duration,
) -> WorkerOptionsBuilder<SetGracefulShutdownPeriod<S>>where
S::GracefulShutdownPeriod: IsUnset,
pub fn graceful_shutdown_period(
self,
value: Duration,
) -> WorkerOptionsBuilder<SetGracefulShutdownPeriod<S>>where
S::GracefulShutdownPeriod: IsUnset,
Sourcepub fn maybe_graceful_shutdown_period(
self,
value: Option<Duration>,
) -> WorkerOptionsBuilder<SetGracefulShutdownPeriod<S>>where
S::GracefulShutdownPeriod: IsUnset,
pub fn maybe_graceful_shutdown_period(
self,
value: Option<Duration>,
) -> WorkerOptionsBuilder<SetGracefulShutdownPeriod<S>>where
S::GracefulShutdownPeriod: IsUnset,
Source§impl<S: State> WorkerOptionsBuilder<S>
impl<S: State> WorkerOptionsBuilder<S>
Sourcepub fn register_activities<AI: ActivityImplementer>(self, instance: AI) -> Self
pub fn register_activities<AI: ActivityImplementer>(self, instance: AI) -> Self
Registers all activities on an activity implementer.
Sourcepub fn register_activity<AD>(self, instance: Arc<AD::Implementer>) -> Self
pub fn register_activity<AD>(self, instance: Arc<AD::Implementer>) -> Self
Registers a specific activitiy.
Sourcepub fn register_workflow<WI: WorkflowImplementer>(self) -> Self
pub fn register_workflow<WI: WorkflowImplementer>(self) -> Self
Registers all workflows on a workflow implementer.
Sourcepub fn register_workflow_with_factory<W, F>(self, factory: F) -> Self
pub fn register_workflow_with_factory<W, F>(self, factory: F) -> Self
Register a workflow with a custom factory for instance creation.
§Warning: Advanced Usage
This method is intended for scenarios requiring injection of un-serializable state into workflows.
This can easily cause nondeterminism
Only use when you understand the implications and have a specific need that cannot be met otherwise.
§Panics
Panics if the workflow type defines an #[init] method. Workflows using
factory registration must not have #[init] to avoid ambiguity about
instance creation.
Auto Trait Implementations§
impl<S> Freeze for WorkerOptionsBuilder<S>
impl<S = Empty> !RefUnwindSafe for WorkerOptionsBuilder<S>
impl<S> Send for WorkerOptionsBuilder<S>
impl<S> Sync for WorkerOptionsBuilder<S>
impl<S> Unpin for WorkerOptionsBuilder<S>
impl<S> UnsafeUnpin for WorkerOptionsBuilder<S>
impl<S = Empty> !UnwindSafe for WorkerOptionsBuilder<S>
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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