Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

Asynq 客户端,负责将任务排队 Asynq client, responsible for enqueuing tasks

Implementations§

Source§

impl Client

Source

pub async fn new(redis_connection: RedisConnectionType) -> Result<Self>

创建新的客户端实例(使用 Redis 后端) Create a new client instance (with Redis backend)

Source

pub async fn with_config( redis_connection: RedisConnectionType, config: ClientConfig, ) -> Result<Self>

使用指定配置创建客户端实例(使用 Redis 后端) Create a client instance with the specified configuration (with Redis backend)

Source

pub fn get_broker(&self) -> Arc<dyn Broker> ⓘ

获取 Broker 实例 Get the Broker instance

Source

pub async fn enqueue(&self, task: Task) -> Result<TaskInfo>

将任务加入队列立即处理 Enqueue a task for immediate processing

Source

pub async fn enqueue_unique( &self, task: Task, ttl: Duration, ) -> Result<TaskInfo>

将唯一任务加入队列 Enqueue a unique task

Source

pub async fn schedule( &self, task: Task, process_at: SystemTime, ) -> Result<TaskInfo>

调度任务在指定时间处理 Schedule a task for processing at a specific time

Source

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

Source

pub async fn enqueue_in(&self, task: Task, delay: Duration) -> Result<TaskInfo>

在指定延迟后处理任务 Enqueue a task to be processed after a specific delay

Source

pub async fn add_to_group(&self, task: Task, group: &str) -> Result<TaskInfo>

将任务添加到组中进行聚合 Add a task to a group for aggregation

Source

pub async fn add_to_group_unique( &self, task: Task, group: &str, ttl: Duration, ) -> Result<TaskInfo>

将唯一任务添加到组中进行聚合 Add a unique task to a group for aggregation

Source

pub async fn ping(&self) -> Result<()>

Ping the backend connection

Source

pub async fn close(&self) -> Result<()>

关闭客户端 Close the client

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> 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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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