Struct Task

Source
pub struct Task(/* private fields */);

Implementations§

Source§

impl Task

Source

pub fn create_new(name: &str) -> Self

Source

pub fn create(&self, name: &str) -> Self

Source

pub async fn spawn_new<F, FT, T>(name: &str, f: F) -> Result<T>
where F: FnOnce(Task) -> FT, FT: Future<Output = Result<T>> + Send, T: Send,

Spawn a new top level task, with no parent. This should usually be done in the very beginning of the process/application.

Source

pub async fn spawn<F, FT, T, S: Into<String>>(&self, name: S, f: F) -> Result<T>
where F: FnOnce(Task) -> FT, FT: Future<Output = Result<T>> + Send, T: Send,

Source

pub fn spawn_sync<F, T, S: Into<String>>(&self, name: S, f: F) -> Result<T>
where F: FnOnce(Task) -> Result<T>, T: Send,

Source

pub fn data<D: Into<DataValue>>(&self, name: &str, data: D)

Source

pub fn get_data(&self, name: &str) -> Option<DataValue>

Get a piece of previously set data or transitive data. This can be useful if session/request tracking IDs need to be past to other loggers, e.g. when shelling out to another process that needs to set the same session_id inside so we can group the events together.

Source

pub fn data_transitive<D: Into<DataValue>>(&self, name: &str, data: D)

Source

pub fn progress(&self, done: i64, total: i64)

Source

pub fn hide_error_msg(&self, msg: Option<String>)

Reporters can use this flag to choose to not report errors. This is useful for cases where there’s a large task chain and every single task reports a partial errors (that gets built up with each task) It would make sense to report it only once at the top level (thrift request, cli call, etc) and only mark other tasks. If set to Some, the message inside is what would be reported by default instead of reporting errors to avoid confusion (e.g. “error was hidden, see …”) see hide_errors_default_msg()

Source

pub fn attach_transitive_data_to_errors(&self, val: bool)

When errors occur, we attach task data to it in the description. If set to false, only task direct data will be attached and not transitive data. This is useful sometimes to remove the noise of transitive data appearing in every error in the chain (e.g. hostname) see attach_transitive_data_to_errors_default()

Trait Implementations§

Source§

impl Clone for Task

Source§

fn clone(&self) -> Task

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 Freeze for Task

§

impl RefUnwindSafe for Task

§

impl Send for Task

§

impl Sync for Task

§

impl Unpin for Task

§

impl UnwindSafe for Task

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.