TaskProcessor

Struct TaskProcessor 

Source
pub struct TaskProcessor;

Implementations§

Source§

impl TaskProcessor

Source

pub async fn init_status( cache_key: &str, task_id: Option<u64>, cache_client: &TardisCacheClient, ) -> TardisResult<u64>

Initialize the asynchronous task status

初始化异步任务状态

Source

pub async fn set_status( cache_key: &str, task_id: u64, status: bool, cache_client: &TardisCacheClient, ) -> TardisResult<()>

Set the status of the asynchronous task (whether it is completed)

设置异步任务状态(是否完成)

Source

pub async fn check_status( cache_key: &str, task_id: u64, cache_client: &TardisCacheClient, ) -> TardisResult<bool>

Check the status of the asynchronous task (whether it is completed)

检查异步任务状态(是否完成)

Source

pub async fn set_status_with_event( cache_key: &str, task_id: u64, status: bool, cache_client: &TardisCacheClient, _from_avatar: String, _to_avatars: Option<Vec<String>>, ) -> TardisResult<()>

Set the status of the asynchronous task (whether it is completed) and send an event

设置异步任务状态(是否完成)并发送事件

Source

pub async fn set_process_data( cache_key: &str, task_id: u64, data: Value, cache_client: &TardisCacheClient, ) -> TardisResult<()>

Set the processing data of the asynchronous task

设置异步任务处理数据

Source

pub async fn set_process_data_with_event( cache_key: &str, task_id: u64, data: Value, cache_client: &TardisCacheClient, _from_avatar: String, _to_avatars: Option<Vec<String>>, ) -> TardisResult<()>

Set the processing data of the asynchronous task and send an event

设置异步任务处理数据并发送事件

Source

pub async fn get_process_data( cache_key: &str, task_id: u64, cache_client: &TardisCacheClient, ) -> TardisResult<Value>

Fetch the processing data of the asynchronous task

获取异步任务处理数据

Source

pub async fn execute_task<P, T>( cache_key: &str, process_fun: P, cache_client: &Arc<TardisCacheClient>, ) -> TardisResult<u64>
where P: FnOnce(u64) -> T + Send + Sync + 'static, T: Future<Output = TardisResult<()>> + Send + 'static,

Execute asynchronous task

执行异步任务

Source

pub async fn execute_task_with_ctx<P, T>( cache_key: &str, process_fun: P, cache_client: &Arc<TardisCacheClient>, from_avatar: String, to_avatars: Option<Vec<String>>, ctx: &TardisContext, ) -> TardisResult<u64>
where P: FnOnce(u64) -> T + Send + Sync + 'static, T: Future<Output = TardisResult<()>> + Send + 'static,

Execute asynchronous task and send event

执行异步任务并发送事件

Source

pub async fn execute_task_without_fun( cache_key: &str, task_id: u64, cache_client: &Arc<TardisCacheClient>, _from_avatar: String, _to_avatars: Option<Vec<String>>, ) -> TardisResult<u64>

Execute asynchronous task (without asynchronous function, only used to mark the start of the task)

执行异步任务(不带异步函数,仅用于标记任务开始执行)

Source

pub async fn stop_task( cache_key: &str, task_id: u64, cache_client: &TardisCacheClient, ) -> TardisResult<()>

Stop asynchronous task

停止异步任务

Source

pub async fn stop_task_with_event( cache_key: &str, task_id: u64, cache_client: &TardisCacheClient, from_avatar: String, to_avatars: Option<Vec<String>>, ) -> TardisResult<()>

Stop asynchronous task and send event

停止异步任务并发送事件

Source

pub async fn get_task_id_with_ctx( ctx: &TardisContext, ) -> TardisResult<Option<String>>

Fetch the asynchronous task id set in the context

获取异步任务id集合

Use , to separate multiple tasks

多个任务使用,分隔

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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