Struct RedisStorage

Source
pub struct RedisStorage<T, Conn = ConnectionManager, C = JsonCodec<Vec<u8>>> { /* private fields */ }
Expand description

Represents a Storage that uses Redis for storage.

Implementations§

Source§

impl<T: Serialize + DeserializeOwned, Conn> RedisStorage<T, Conn, JsonCodec<Vec<u8>>>

Source

pub fn new(conn: Conn) -> RedisStorage<T, Conn, JsonCodec<Vec<u8>>>

Start a new connection

Source

pub fn new_with_config( conn: Conn, config: Config, ) -> RedisStorage<T, Conn, JsonCodec<Vec<u8>>>

Start a connection with a custom config

Source

pub fn new_with_codec<K>(conn: Conn, config: Config) -> RedisStorage<T, Conn, K>
where K: Codec + Sync + Send + 'static,

Start a new connection providing custom config and a codec

Source

pub fn get_connection(&self) -> &Conn

Get current connection

Source

pub fn get_config(&self) -> &Config

Get the config used by the storage

Source§

impl<T, Conn, C> RedisStorage<T, Conn, C>

Source

pub fn get_codec(&self) -> &PhantomData<C>

Get the underlying codec details

Source§

impl<T, Conn, C> RedisStorage<T, Conn, C>
where Conn: ConnectionLike + Send + Sync + 'static, C: Codec<Compact = Vec<u8>> + Send + 'static,

Source

pub async fn retry( &mut self, worker_id: &WorkerId, task_id: &TaskId, ) -> Result<i32, RedisError>
where T: Send + DeserializeOwned + Serialize + Unpin + Sync + 'static,

Attempt to retry a job

Source

pub async fn kill( &mut self, worker_id: &WorkerId, task_id: &TaskId, error: &BoxDynError, ) -> Result<(), RedisError>

Attempt to kill a job

Source

pub async fn enqueue_scheduled( &mut self, count: usize, ) -> Result<usize, RedisError>

Required to add scheduled jobs to the active set

Source

pub async fn reenqueue_active( &mut self, job_ids: Vec<&TaskId>, ) -> Result<(), RedisError>

Re-enqueue some jobs that might be abandoned.

Source

pub async fn reenqueue_orphaned( &mut self, count: i32, dead_since: DateTime<Utc>, ) -> Result<usize, RedisError>

Re-enqueue some jobs that might be orphaned after a number of seconds

Trait Implementations§

Source§

impl<T, Conn, C, Res> Ack<T, Res, C> for RedisStorage<T, Conn, C>
where T: Sync + Send + Serialize + DeserializeOwned + Unpin + 'static, Conn: ConnectionLike + Send + Sync + 'static, C: Codec<Compact = Vec<u8>> + Send + 'static, Res: Serialize + Sync + Send + 'static,

Source§

type Context = RedisContext

The data to fetch from context to allow acknowledgement
Source§

type AckError = RedisError

The error returned by the ack
Source§

async fn ack( &mut self, ctx: &Self::Context, res: &Response<Res>, ) -> Result<(), RedisError>

Acknowledges successful processing of the given request
Source§

impl<T, Conn, C> Backend<Request<T, RedisContext>> for RedisStorage<T, Conn, C>
where T: Serialize + DeserializeOwned + Sync + Send + Unpin + 'static, Conn: ConnectionLike + Send + Sync + 'static, C: Codec<Compact = Vec<u8>> + Send + 'static,

Source§

type Stream = BackendStream<Pin<Box<dyn Stream<Item = Result<Option<Request<T, RedisContext>>, Error>> + Send>>>

The stream to be produced by the backend
Source§

type Layer = AckLayer<Sender<(RedisContext, Response<Vec<u8>>)>, T, RedisContext, C>

Returns the final decoration of layers
Source§

type Codec = C

Specifies the codec type used by the backend
Source§

fn poll(self, worker: &Worker<Context>) -> Poller<Self::Stream, Self::Layer>

Returns a poller that is ready for streaming
Source§

impl<T> BackendExpose<T> for RedisStorage<T>
where T: 'static + Serialize + DeserializeOwned + Send + Unpin + Sync,

Source§

type Request = Request<T, RedisContext>

The request type being handled by the backend
Source§

type Error = RedisError

The error returned during reading jobs and stats
Source§

async fn stats(&self) -> Result<Stat, RedisError>

Returns the counts of jobs in different states
Source§

async fn list_jobs( &self, status: &State, page: i32, ) -> Result<Vec<Self::Request>, RedisError>

Fetch jobs persisted in a backend
Source§

async fn list_workers(&self) -> Result<Vec<Worker<WorkerState>>, RedisError>

List all Workers that are working on a backend
Source§

impl<T, Conn: Clone, C> Clone for RedisStorage<T, Conn, C>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T, Conn, C> Debug for RedisStorage<T, Conn, C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, Conn, C> Storage for RedisStorage<T, Conn, C>
where T: Serialize + DeserializeOwned + Send + 'static + Unpin + Sync, Conn: ConnectionLike + Send + Sync + 'static, C: Codec<Compact = Vec<u8>> + Send + 'static,

Source§

type Job = T

The type of job that can be persisted
Source§

type Error = RedisError

The error produced by the storage
Source§

type Context = RedisContext

This is the type that storages store as the metadata related to a job
Source§

type Compact = Vec<u8>

The format that the storage persists the jobs usually Vec<u8>
Source§

async fn push_request( &mut self, req: Request<T, RedisContext>, ) -> Result<Parts<Self::Context>, RedisError>

Pushes a constructed request to a storage
Source§

async fn push_raw_request( &mut self, req: Request<Self::Compact, Self::Context>, ) -> Result<Parts<Self::Context>, Self::Error>

Pushes a constructed request to a storage
Source§

async fn schedule_request( &mut self, req: Request<Self::Job, RedisContext>, on: i64, ) -> Result<Parts<Self::Context>, RedisError>

Push a request into the scheduled set
Source§

async fn len(&mut self) -> Result<i64, RedisError>

Return the number of pending jobs from the queue
Source§

async fn fetch_by_id( &mut self, job_id: &TaskId, ) -> Result<Option<Request<Self::Job, RedisContext>>, RedisError>

Fetch a job given an id
Source§

async fn update( &mut self, job: Request<T, RedisContext>, ) -> Result<(), RedisError>

Update a job details
Source§

async fn reschedule( &mut self, job: Request<T, RedisContext>, wait: Duration, ) -> Result<(), RedisError>

Reschedule a job
Source§

async fn is_empty(&mut self) -> Result<bool, RedisError>

Returns true if there is no jobs in the storage
Source§

async fn vacuum(&mut self) -> Result<usize, RedisError>

Vacuum the storage, removes done and killed jobs
Source§

fn push( &mut self, job: Self::Job, ) -> impl Future<Output = Result<Parts<Self::Context>, Self::Error>> + Send

Pushes a job to a storage
Source§

fn schedule( &mut self, job: Self::Job, on: i64, ) -> impl Future<Output = Result<Parts<Self::Context>, Self::Error>> + Send

Push a job with defaults into the scheduled set

Auto Trait Implementations§

§

impl<T, Conn, C> Freeze for RedisStorage<T, Conn, C>
where Conn: Freeze,

§

impl<T, Conn, C> RefUnwindSafe for RedisStorage<T, Conn, C>

§

impl<T, Conn, C> Send for RedisStorage<T, Conn, C>
where Conn: Send, T: Send, C: Send,

§

impl<T, Conn, C> Sync for RedisStorage<T, Conn, C>
where Conn: Sync, T: Sync, C: Sync,

§

impl<T, Conn, C> Unpin for RedisStorage<T, Conn, C>
where Conn: Unpin, T: Unpin, C: Unpin,

§

impl<T, Conn, C> UnwindSafe for RedisStorage<T, Conn, C>
where Conn: UnwindSafe, T: UnwindSafe, C: UnwindSafe,

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