TaskEvent

Struct TaskEvent 

Source
pub struct TaskEvent {
Show 17 fields pub base: EventMessage, pub uuid: Uuid, pub name: Option<String>, pub args: Option<String>, pub kwargs: Option<String>, pub retries: Option<u32>, pub eta: Option<String>, pub expires: Option<String>, pub parent_id: Option<Uuid>, pub root_id: Option<Uuid>, pub result: Option<Value>, pub exception: Option<String>, pub traceback: Option<String>, pub runtime: Option<f64>, pub queue: Option<String>, pub exchange: Option<String>, pub routing_key: Option<String>,
}
Expand description

Task-specific event data

Fields§

§base: EventMessage

Base event

§uuid: Uuid

Task ID (UUID)

§name: Option<String>

Task name

§args: Option<String>

Task arguments (as JSON string)

§kwargs: Option<String>

Task keyword arguments (as JSON string)

§retries: Option<u32>

Retry count

§eta: Option<String>

ETA for delayed tasks

§expires: Option<String>

Task expiration

§parent_id: Option<Uuid>

Parent task ID

§root_id: Option<Uuid>

Root task ID

§result: Option<Value>

Result (for task-succeeded)

§exception: Option<String>

Exception type (for task-failed)

§traceback: Option<String>

Traceback (for task-failed)

§runtime: Option<f64>

Runtime in seconds (for task-succeeded)

§queue: Option<String>

Queue name

§exchange: Option<String>

Exchange name

§routing_key: Option<String>

Routing key

Implementations§

Source§

impl TaskEvent

Source

pub fn new(event_type: EventType, task_id: Uuid) -> Self

Create a new task event

Source

pub fn sent(task_id: Uuid, task_name: &str) -> Self

Create a task-sent event

Source

pub fn received(task_id: Uuid, task_name: &str) -> Self

Create a task-received event

Source

pub fn started(task_id: Uuid, task_name: &str) -> Self

Create a task-started event

Source

pub fn succeeded(task_id: Uuid, result: Value, runtime: f64) -> Self

Create a task-succeeded event

Source

pub fn failed(task_id: Uuid, exception: &str, traceback: Option<&str>) -> Self

Create a task-failed event

Source

pub fn retried(task_id: Uuid, exception: &str, retries: u32) -> Self

Create a task-retried event

Source

pub fn revoked(task_id: Uuid, terminated: bool, signum: Option<i32>) -> Self

Create a task-revoked event

Source

pub fn rejected(task_id: Uuid, requeue: bool) -> Self

Create a task-rejected event

Source

pub fn with_name(self, name: impl Into<String>) -> Self

Set task name

Source

pub fn with_args(self, args: impl Into<String>) -> Self

Set task args

Source

pub fn with_kwargs(self, kwargs: impl Into<String>) -> Self

Set task kwargs

Source

pub fn with_hostname(self, hostname: impl Into<String>) -> Self

Set hostname

Source

pub fn with_queue(self, queue: impl Into<String>) -> Self

Set queue

Source

pub fn with_parent(self, parent_id: Uuid) -> Self

Set parent task ID

Source

pub fn with_root(self, root_id: Uuid) -> Self

Set root task ID

Source

pub fn to_json(&self) -> Result<Vec<u8>, Error>

Serialize to JSON bytes

Source

pub fn from_json(bytes: &[u8]) -> Result<Self, Error>

Deserialize from JSON bytes

Trait Implementations§

Source§

impl Clone for TaskEvent

Source§

fn clone(&self) -> TaskEvent

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

impl Debug for TaskEvent

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for TaskEvent

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for TaskEvent

Source§

fn eq(&self, other: &TaskEvent) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for TaskEvent

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TaskEvent

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,