pub struct MysqlStorage<T> { /* private fields */ }
Available on crate feature mysql only.
Expand description

Represents a Storage that persists to MySQL

Implementations§

source§

impl MysqlStorage<()>

source

pub fn migrations() -> Migrator

Get mysql migrations without running them

source

pub async fn setup(pool: &Pool<MySql>) -> Result<(), Error>

Do migrations for mysql

source§

impl<T: Serialize + DeserializeOwned> MysqlStorage<T>

source

pub fn new(pool: MySqlPool) -> Self

Create a new instance from a pool

source

pub fn new_with_config(pool: MySqlPool, config: Config) -> Self

Create a new instance from a pool and custom config

source

pub fn pool(&self) -> &Pool<MySql>

Expose the pool for other functionality, eg custom migrations

source§

impl<T: Job> MysqlStorage<T>

source

pub async fn kill( &mut self, worker_id: &WorkerId, job_id: &TaskId ) -> Result<(), Error>

Kill a job

source

pub async fn retry( &mut self, worker_id: &WorkerId, job_id: &TaskId ) -> Result<(), Error>

Puts the job instantly back into the queue

source

pub async fn reenqueue_orphaned(&self, timeout: i64) -> Result<bool, Error>

Readd jobs that are abandoned to the queue

Trait Implementations§

source§

impl<T: Sync> Ack<T> for MysqlStorage<T>

§

type Acknowledger = TaskId

The data to fetch from context to allow acknowledgement
§

type Error = Error

The error returned by the ack
source§

async fn ack( &self, worker_id: &WorkerId, task_id: &Self::Acknowledger ) -> Result<(), Error>

Acknowledges successful processing of the given request
source§

impl<T: Job + Serialize + DeserializeOwned + Sync + Send + Unpin + 'static> Backend<Request<T>> for MysqlStorage<T>

§

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

The stream to be produced by the backend
§

type Layer = AckLayer<MysqlStorage<T>, T>

Returns the final decoration of layers
source§

fn common_layer(&self, worker_id: WorkerId) -> Self::Layer

Allows the backend to decorate the service with Layer
source§

fn poll(self, worker: WorkerId) -> Poller<Self::Stream>

Returns a poller that is ready for streaming
source§

impl<T> Clone for MysqlStorage<T>

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> Debug for MysqlStorage<T>

source§

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

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

impl<T> Storage for MysqlStorage<T>
where T: Job + Serialize + DeserializeOwned + Send + 'static + Unpin + Sync,

§

type Job = T

The type of job that can be persisted
§

type Error = Error

The error produced by the storage
§

type Identifier = TaskId

Jobs must have Ids.
source§

async fn push(&mut self, job: Self::Job) -> Result<TaskId, Error>

Pushes a job to a storage
source§

async fn schedule(&mut self, job: Self::Job, on: i64) -> Result<TaskId, Error>

Push a job into the scheduled set
source§

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

Fetch a job given an id
source§

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

Return the number of pending jobs from the queue
source§

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

Reschedule a job
source§

async fn update(&self, job: Request<Self::Job>) -> Result<(), Error>

Update a job details
source§

async fn is_empty(&self) -> Result<bool, Self::Error>

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

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

Vacuum the storage, removes done and killed jobs

Auto Trait Implementations§

§

impl<T> Freeze for MysqlStorage<T>

§

impl<T> !RefUnwindSafe for MysqlStorage<T>

§

impl<T> Send for MysqlStorage<T>
where T: Send,

§

impl<T> Sync for MysqlStorage<T>
where T: Sync,

§

impl<T> Unpin for MysqlStorage<T>
where T: Unpin,

§

impl<T> !UnwindSafe for MysqlStorage<T>

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> 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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

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

§

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

§

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