DistributedWorker

Struct DistributedWorker 

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

Source

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.

Source

pub fn set_retry_policy(&mut self, policy: RetryPolicy)

Set a retry policy for all work items.

Source

pub async fn run_once( &self, worker_id: usize, ) -> Result<Option<(String, W::Output)>, FloxideError>
where C: Debug + Clone + Send + Sync,

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.

Source

pub async fn run_forever(&self, worker_id: usize) -> Infallible
where C: Debug + Clone + Send + Sync,

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).

Source

pub async fn heartbeat(&self, worker_id: usize)
where C: Debug + Clone + Send + Sync,

Heartbeat: update liveness store with current timestamp and update health.

§Instrumentation

This method is instrumented with tracing for async span tracking.

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,

Source§

fn clone(&self) -> DistributedWorker<W, C, Q, RIS, MS, ES, LS, WISS, CS>

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§

§

impl<W, C, Q, RIS, MS, ES, LS, WISS, CS> Freeze for DistributedWorker<W, C, Q, RIS, MS, ES, LS, WISS, CS>
where W: Freeze, Q: Freeze, CS: Freeze, RIS: Freeze, MS: Freeze, ES: Freeze, LS: Freeze, WISS: Freeze,

§

impl<W, C, Q, RIS, MS, ES, LS, WISS, CS> RefUnwindSafe for DistributedWorker<W, C, Q, RIS, MS, ES, LS, WISS, CS>

§

impl<W, C, Q, RIS, MS, ES, LS, WISS, CS> Send for DistributedWorker<W, C, Q, RIS, MS, ES, LS, WISS, CS>

§

impl<W, C, Q, RIS, MS, ES, LS, WISS, CS> Sync for DistributedWorker<W, C, Q, RIS, MS, ES, LS, WISS, CS>

§

impl<W, C, Q, RIS, MS, ES, LS, WISS, CS> Unpin for DistributedWorker<W, C, Q, RIS, MS, ES, LS, WISS, CS>
where W: Unpin, Q: Unpin, CS: Unpin, RIS: Unpin, MS: Unpin, ES: Unpin, LS: Unpin, WISS: Unpin, C: Unpin,

§

impl<W, C, Q, RIS, MS, ES, LS, WISS, CS> UnwindSafe for DistributedWorker<W, C, Q, RIS, MS, ES, LS, WISS, CS>

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