Skip to main content

WorkerOutput

Enum WorkerOutput 

Source
pub enum WorkerOutput {
    Completed(HashMap<String, Value>),
    Failed(String),
    FailedWithTerminalError(String),
    InProgress(TaskInProgress),
}
Expand description

Output type for worker execution.

Variants§

§

Completed(HashMap<String, Value>)

Task completed successfully with output.

§

Failed(String)

Task failed with an error message — retried by the server per the task’s retry policy.

§

FailedWithTerminalError(String)

Task failed permanently and should not be retried (FAILED_WITH_TERMINAL_ERROR).

Return this instead of WorkerOutput::Failed — or instead of a plain Err from Worker::execute, which always maps to WorkerOutput::Failed in task_runner.rs — when the failure is definitively not worth retrying (a malformed input that will fail identically every time, a missing local dependency like an interpreter binary, etc.). There is currently no way to signal this from an Err return; a worker that needs it must construct this variant directly and return it via Ok(...).

§

InProgress(TaskInProgress)

Task is still in progress (for long-running tasks).

Implementations§

Source§

impl WorkerOutput

Source

pub fn completed_with_result(result: impl Serialize) -> Self

Create a completed output with a single result value.

Source

pub fn completed(output: HashMap<String, Value>) -> Self

Create a completed output with a map.

Source

pub fn complete() -> Self

Create a completed output with no data.

Source

pub fn failed(reason: impl Into<String>) -> Self

Create a failed output.

Source

pub fn in_progress(callback_after_seconds: i64) -> Self

Create an in-progress output.

Source

pub fn into_task_result(self, task: &Task, worker_id: &str) -> TaskResult

Convert to TaskResult.

Trait Implementations§

Source§

impl Clone for WorkerOutput

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for WorkerOutput

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> 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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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