pub struct DistributedWorker<W, C, Q, RIS, MS, ES, LS, WISS, CS>where
W: Workflow<C, WorkItem: 'static>,
C: Context + Merge + Default,
Q: WorkQueue<C, W::WorkItem> + Send + Sync + 'static,
RIS: RunInfoStore + Send + Sync,
MS: MetricsStore + Send + Sync,
ES: ErrorStore + Send + Sync,
LS: LivenessStore + Send + Sync,
WISS: WorkItemStateStore<W::WorkItem> + Send + Sync,
CS: ContextStore<C> + Send + Sync + Clone + 'static,{ /* private fields */ }Expand description
A distributed workflow worker that polls a work queue, processes workflow steps, and updates state in distributed stores.
Use [run_once] to process a single work item, or [run_forever] to continuously poll for work.
Implementations§
Source§impl<W, C, Q, RIS, MS, ES, LS, WISS, CS> DistributedWorker<W, C, Q, RIS, MS, ES, LS, WISS, CS>where
W: Workflow<C, WorkItem: 'static> + 'static,
C: Context + Merge + Default + 'static,
Q: WorkQueue<C, W::WorkItem> + Send + Sync + Clone,
RIS: RunInfoStore + Send + Sync + Clone + 'static,
MS: MetricsStore + Send + Sync + Clone + 'static,
ES: ErrorStore + Send + Sync + Clone + 'static,
LS: LivenessStore + Send + Sync + Clone + 'static,
WISS: WorkItemStateStore<W::WorkItem> + Send + Sync + Clone + 'static,
CS: ContextStore<C> + Send + Sync + Clone + 'static,
Self: Clone,
impl<W, C, Q, RIS, MS, ES, LS, WISS, CS> DistributedWorker<W, C, Q, RIS, MS, ES, LS, WISS, CS>where
W: Workflow<C, WorkItem: 'static> + 'static,
C: Context + Merge + Default + 'static,
Q: WorkQueue<C, W::WorkItem> + Send + Sync + Clone,
RIS: RunInfoStore + Send + Sync + Clone + 'static,
MS: MetricsStore + Send + Sync + Clone + 'static,
ES: ErrorStore + Send + Sync + Clone + 'static,
LS: LivenessStore + Send + Sync + Clone + 'static,
WISS: WorkItemStateStore<W::WorkItem> + Send + Sync + Clone + 'static,
CS: ContextStore<C> + Send + Sync + Clone + 'static,
Self: Clone,
Sourcepub fn new(
workflow: W,
queue: Q,
context_store: CS,
run_info_store: RIS,
metrics_store: MS,
error_store: ES,
liveness_store: LS,
work_item_state_store: WISS,
) -> Self
pub fn new( workflow: W, queue: Q, context_store: CS, run_info_store: RIS, metrics_store: MS, error_store: ES, liveness_store: LS, work_item_state_store: WISS, ) -> Self
Create a new distributed worker with all required stores and workflow.
See WorkerBuilder for ergonomic construction with defaults.
Sourcepub fn set_retry_policy(&mut self, policy: RetryPolicy)
pub fn set_retry_policy(&mut self, policy: RetryPolicy)
Set a retry policy for all work items.
Sourcepub async fn run_once(
&self,
worker_id: usize,
) -> Result<Option<(String, W::Output)>, FloxideError>
pub async fn run_once( &self, worker_id: usize, ) -> Result<Option<(String, W::Output)>, FloxideError>
Process a single work item from the queue, updating all distributed state.
Returns Ok(Some((run_id, output))) if a work item was processed, Ok(None) if no work was available, or Err on permanent failure.
§Instrumentation
This method is instrumented with tracing for async span tracking.
Sourcepub async fn run_forever(&self, worker_id: usize) -> Infallible
pub async fn run_forever(&self, worker_id: usize) -> Infallible
Continuously poll for work and process items, sleeping briefly when idle or on error.
This method never returns and is suitable for running in a background task.
§Instrumentation
This method is instrumented with tracing for async span tracking.
Note: Returns std::convert::Infallible for compatibility with stable Rust (instead of the experimental ! type).
Trait Implementations§
Source§impl<W, C, Q, RIS, MS, ES, LS, WISS, CS> Clone for DistributedWorker<W, C, Q, RIS, MS, ES, LS, WISS, CS>where
W: Workflow<C, WorkItem: 'static> + Clone,
C: Context + Merge + Default + Clone,
Q: WorkQueue<C, W::WorkItem> + Send + Sync + 'static + Clone,
RIS: RunInfoStore + Send + Sync + Clone,
MS: MetricsStore + Send + Sync + Clone,
ES: ErrorStore + Send + Sync + Clone,
LS: LivenessStore + Send + Sync + Clone,
WISS: WorkItemStateStore<W::WorkItem> + Send + Sync + Clone,
CS: ContextStore<C> + Send + Sync + Clone + 'static + Clone,
impl<W, C, Q, RIS, MS, ES, LS, WISS, CS> Clone for DistributedWorker<W, C, Q, RIS, MS, ES, LS, WISS, CS>where
W: Workflow<C, WorkItem: 'static> + Clone,
C: Context + Merge + Default + Clone,
Q: WorkQueue<C, W::WorkItem> + Send + Sync + 'static + Clone,
RIS: RunInfoStore + Send + Sync + Clone,
MS: MetricsStore + Send + Sync + Clone,
ES: ErrorStore + Send + Sync + Clone,
LS: LivenessStore + Send + Sync + Clone,
WISS: WorkItemStateStore<W::WorkItem> + Send + Sync + Clone,
CS: ContextStore<C> + Send + Sync + Clone + 'static + Clone,
Source§fn clone(&self) -> DistributedWorker<W, C, Q, RIS, MS, ES, LS, WISS, CS>
fn clone(&self) -> DistributedWorker<W, C, Q, RIS, MS, ES, LS, WISS, CS>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more