pub struct TaskProcessor;Implementations§
Source§impl TaskProcessor
impl TaskProcessor
Sourcepub async fn init_status(
cache_key: &str,
task_id: Option<u64>,
cache_client: &TardisCacheClient,
) -> TardisResult<u64>
pub async fn init_status( cache_key: &str, task_id: Option<u64>, cache_client: &TardisCacheClient, ) -> TardisResult<u64>
Initialize the asynchronous task status
初始化异步任务状态
Sourcepub async fn set_status(
cache_key: &str,
task_id: u64,
status: bool,
cache_client: &TardisCacheClient,
) -> TardisResult<()>
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)
设置异步任务状态(是否完成)
Sourcepub async fn check_status(
cache_key: &str,
task_id: u64,
cache_client: &TardisCacheClient,
) -> TardisResult<bool>
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)
检查异步任务状态(是否完成)
Sourcepub 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<()>
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
设置异步任务状态(是否完成)并发送事件
Sourcepub async fn set_process_data(
cache_key: &str,
task_id: u64,
data: Value,
cache_client: &TardisCacheClient,
) -> TardisResult<()>
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
设置异步任务处理数据
Sourcepub 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<()>
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
设置异步任务处理数据并发送事件
Sourcepub async fn get_process_data(
cache_key: &str,
task_id: u64,
cache_client: &TardisCacheClient,
) -> TardisResult<Value>
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
获取异步任务处理数据
Sourcepub async fn execute_task<P, T>(
cache_key: &str,
process_fun: P,
cache_client: &Arc<TardisCacheClient>,
) -> TardisResult<u64>
pub async fn execute_task<P, T>( cache_key: &str, process_fun: P, cache_client: &Arc<TardisCacheClient>, ) -> TardisResult<u64>
Execute asynchronous task
执行异步任务
Sourcepub 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>
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>
Execute asynchronous task and send event
执行异步任务并发送事件
Sourcepub 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>
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)
执行异步任务(不带异步函数,仅用于标记任务开始执行)
Sourcepub async fn stop_task(
cache_key: &str,
task_id: u64,
cache_client: &TardisCacheClient,
) -> TardisResult<()>
pub async fn stop_task( cache_key: &str, task_id: u64, cache_client: &TardisCacheClient, ) -> TardisResult<()>
Stop asynchronous task
停止异步任务
Sourcepub async fn stop_task_with_event(
cache_key: &str,
task_id: u64,
cache_client: &TardisCacheClient,
from_avatar: String,
to_avatars: Option<Vec<String>>,
) -> TardisResult<()>
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
停止异步任务并发送事件
Sourcepub async fn get_task_id_with_ctx(
ctx: &TardisContext,
) -> TardisResult<Option<String>>
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§
impl Freeze for TaskProcessor
impl RefUnwindSafe for TaskProcessor
impl Send for TaskProcessor
impl Sync for TaskProcessor
impl Unpin for TaskProcessor
impl UnwindSafe for TaskProcessor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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