Struct QueueService

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

Service responsible for managing a Redis queue.

Implementations§

Source§

impl QueueService

Source

pub fn new(conn: Connection) -> Self

Creates a new QueueService.

§Arguments
  • conn - The Redis connection.
§Returns

A new instance of QueueService.

Source

pub async fn connect() -> Connection

Connects to the Redis server.

§Returns

A Redis connection.

Trait Implementations§

Source§

impl QueueServiceTrait for QueueService

Source§

fn add_job<'life0, 'life1, 'async_trait>( &'life0 mut self, queue_name: &'life1 str, job: JobData, ) -> Pin<Box<dyn Future<Output = RedisResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Adds a job to the specified queue.

§Arguments
  • queue_name - The name of the queue to add the job to.
  • job - The job data to add to the queue.
§Returns

A RedisResult indicating the success or failure of the operation.

Source§

fn get_next_job<'life0, 'life1, 'async_trait>( &'life0 mut self, queue_name: &'life1 str, ) -> Pin<Box<dyn Future<Output = RedisResult<Option<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieves the next job from the specified queue.

§Arguments
  • queue_name - The name of the queue to retrieve the job from.
§Returns

A RedisResult containing an optional job JSON string.

Source§

fn count_jobs<'life0, 'life1, 'async_trait>( &'life0 mut self, queue_name: &'life1 str, ) -> Pin<Box<dyn Future<Output = RedisResult<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Counts the number of jobs in the specified queue.

§Arguments
  • queue_name - The name of the queue to count the jobs in.
§Returns

A RedisResult containing the number of jobs in the queue.

Source§

fn move_to_failed<'life0, 'life1, 'async_trait>( &'life0 mut self, queue_name: &'life1 str, job: JobData, ) -> Pin<Box<dyn Future<Output = RedisResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Moves a job to the failed queue.

§Arguments
  • queue_name - The name of the queue the job belongs to.
  • job - The job data to move to the failed queue.
§Returns

A RedisResult indicating the success or failure of the operation.

Source§

fn log_job_status<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, queue_name: &'life1 str, job: &'life2 JobData, status: &'life3 str, ) -> Pin<Box<dyn Future<Output = RedisResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Logs the status of a job.

§Arguments
  • queue_name - The name of the queue the job belongs to.
  • job - A reference to the job data.
  • status - The status message to log.
§Returns

A RedisResult indicating the success or failure of the operation.

Source§

fn update_job_progress<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, queue_name: &'life1 str, job_id: &'life2 str, progress: u32, ) -> Pin<Box<dyn Future<Output = RedisResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Updates the progress of a job.

§Arguments
  • queue_name - The name of the queue the job belongs to.
  • job_id - The ID of the job.
  • progress - The progress value to update.
§Returns

A RedisResult indicating the success or failure of the operation.

Source§

fn get_job_progress<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, queue_name: &'life1 str, job_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = RedisResult<u32>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Retrieves the progress of a job.

§Arguments
  • queue_name - The name of the queue the job belongs to.
  • job_id - The ID of the job.
§Returns

A RedisResult containing the progress value of the job.

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, 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, 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<T> ErasedDestructor for T
where T: 'static,