pub struct Client { /* private fields */ }Expand description
Asynq 客户端,负责将任务排队 Asynq client, responsible for enqueuing tasks
Implementations§
Source§impl Client
impl Client
Sourcepub async fn new(redis_connection: RedisConnectionType) -> Result<Self>
pub async fn new(redis_connection: RedisConnectionType) -> Result<Self>
创建新的客户端实例(使用 Redis 后端) Create a new client instance (with Redis backend)
Sourcepub async fn with_config(
redis_connection: RedisConnectionType,
config: ClientConfig,
) -> Result<Self>
pub async fn with_config( redis_connection: RedisConnectionType, config: ClientConfig, ) -> Result<Self>
使用指定配置创建客户端实例(使用 Redis 后端) Create a client instance with the specified configuration (with Redis backend)
Sourcepub fn get_broker(&self) -> Arc<dyn Broker> ⓘ
pub fn get_broker(&self) -> Arc<dyn Broker> ⓘ
获取 Broker 实例 Get the Broker instance
Sourcepub async fn enqueue(&self, task: Task) -> Result<TaskInfo>
pub async fn enqueue(&self, task: Task) -> Result<TaskInfo>
将任务加入队列立即处理 Enqueue a task for immediate processing
Sourcepub async fn enqueue_unique(
&self,
task: Task,
ttl: Duration,
) -> Result<TaskInfo>
pub async fn enqueue_unique( &self, task: Task, ttl: Duration, ) -> Result<TaskInfo>
将唯一任务加入队列 Enqueue a unique task
Sourcepub async fn schedule(
&self,
task: Task,
process_at: SystemTime,
) -> Result<TaskInfo>
pub async fn schedule( &self, task: Task, process_at: SystemTime, ) -> Result<TaskInfo>
调度任务在指定时间处理 Schedule a task for processing at a specific time
Sourcepub async fn schedule_unique(
&self,
task: Task,
process_at: SystemTime,
ttl: Duration,
) -> Result<TaskInfo>
pub async fn schedule_unique( &self, task: Task, process_at: SystemTime, ttl: Duration, ) -> Result<TaskInfo>
调度唯一任务在指定时间处理 Schedule a unique task for processing at a specific time
Sourcepub async fn enqueue_in(&self, task: Task, delay: Duration) -> Result<TaskInfo>
pub async fn enqueue_in(&self, task: Task, delay: Duration) -> Result<TaskInfo>
在指定延迟后处理任务 Enqueue a task to be processed after a specific delay
Sourcepub async fn add_to_group(&self, task: Task, group: &str) -> Result<TaskInfo>
pub async fn add_to_group(&self, task: Task, group: &str) -> Result<TaskInfo>
将任务添加到组中进行聚合 Add a task to a group for aggregation
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
impl UnwindSafe for Client
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
Mutably borrows from an owned value. Read more