PostgresStorage

Struct PostgresStorage 

Source
pub struct PostgresStorage<Args, Compact = CompactType, Codec = JsonCodec<CompactType>, Fetcher = PgFetcher<Args, Compact, Codec>> { /* private fields */ }

Implementations§

Source§

impl PostgresStorage<(), (), ()>

Source

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

Perform migrations for storage

Source

pub fn migrations() -> Migrator

Get postgres migrations without running them

Source§

impl<Args> PostgresStorage<Args>

Source

pub fn new(pool: &PgPool) -> Self

Source

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

Creates a new PostgresStorage instance.

Source

pub fn new_with_notify( pool: &PgPool, config: &Config, ) -> PostgresStorage<Args, CompactType, JsonCodec<CompactType>, PgNotify>

Source

pub fn pool(&self) -> &PgPool

Returns a reference to the pool.

Source

pub fn config(&self) -> &Config

Returns a reference to the config.

Source§

impl<Args, Compact, Codec, Fetcher> PostgresStorage<Args, Compact, Codec, Fetcher>

Source

pub fn with_codec<NewCodec>( self, ) -> PostgresStorage<Args, Compact, NewCodec, Fetcher>

Trait Implementations§

Source§

impl<Args, Decode> Backend for PostgresStorage<Args, CompactType, Decode, PgFetcher<Args, CompactType, Decode>>
where Args: Send + 'static + Unpin, Decode: Codec<Args, Compact = CompactType> + Send + 'static, Decode::Error: Error + Send + Sync + 'static,

Source§

type Args = Args

The type of arguments the backend handles.
Source§

type Compact = Vec<u8>

The compact representation of task arguments.
Source§

type IdType = Ulid

The type used to uniquely identify tasks.
Source§

type Context = SqlContext

Context associated with each task.
Source§

type Codec = Decode

The codec used for serialization/deserialization of tasks.
Source§

type Error = Error

The error type returned by backend operations
Source§

type Stream = Pin<Box<dyn Stream<Item = Result<Option<Task<Args, SqlContext, Ulid>>, Error>> + Send>>

A stream of tasks provided by the backend.
Source§

type Beat = Pin<Box<dyn Stream<Item = Result<(), Error>> + Send>>

A stream representing heartbeat signals.
Source§

type Layer = Stack<LockTaskLayer, AcknowledgeLayer<PgAck>>

The type representing backend middleware layer.
Source§

fn heartbeat(&self, worker: &WorkerContext) -> Self::Beat

Returns a heartbeat stream for the given worker.
Source§

fn middleware(&self) -> Self::Layer

Returns the backend’s middleware layer.
Source§

fn poll(self, worker: &WorkerContext) -> Self::Stream

Polls the backend for tasks for the given worker.
Source§

impl<Args, Decode> Backend for PostgresStorage<Args, CompactType, Decode, PgNotify>
where Args: Send + 'static + Unpin, Decode: Codec<Args, Compact = CompactType> + 'static + Send, Decode::Error: Error + Send + Sync + 'static,

Source§

type Args = Args

The type of arguments the backend handles.
Source§

type Compact = Vec<u8>

The compact representation of task arguments.
Source§

type IdType = Ulid

The type used to uniquely identify tasks.
Source§

type Context = SqlContext

Context associated with each task.
Source§

type Codec = Decode

The codec used for serialization/deserialization of tasks.
Source§

type Error = Error

The error type returned by backend operations
Source§

type Stream = Pin<Box<dyn Stream<Item = Result<Option<Task<Args, SqlContext, Ulid>>, Error>> + Send>>

A stream of tasks provided by the backend.
Source§

type Beat = Pin<Box<dyn Stream<Item = Result<(), Error>> + Send>>

A stream representing heartbeat signals.
Source§

type Layer = Stack<LockTaskLayer, AcknowledgeLayer<PgAck>>

The type representing backend middleware layer.
Source§

fn heartbeat(&self, worker: &WorkerContext) -> Self::Beat

Returns a heartbeat stream for the given worker.
Source§

fn middleware(&self) -> Self::Layer

Returns the backend’s middleware layer.
Source§

fn poll(self, worker: &WorkerContext) -> Self::Stream

Polls the backend for tasks for the given worker.
Source§

impl<Args, Decode> Backend for PostgresStorage<Args, CompactType, Decode, SharedFetcher>
where Args: Send + 'static + Unpin, Decode: Codec<Args, Compact = CompactType> + 'static + Unpin + Send, Decode::Error: Error + Send + Sync + 'static,

Source§

type Args = Args

The type of arguments the backend handles.
Source§

type Compact = Vec<u8>

The compact representation of task arguments.
Source§

type IdType = Ulid

The type used to uniquely identify tasks.
Source§

type Error = Error

The error type returned by backend operations
Source§

type Stream = Pin<Box<dyn Stream<Item = Result<Option<Task<Args, SqlContext, Ulid>>, <PostgresStorage<Args, Vec<u8>, Decode, SharedFetcher> as Backend>::Error>> + Send>>

A stream of tasks provided by the backend.
Source§

type Beat = Pin<Box<dyn Stream<Item = Result<(), <PostgresStorage<Args, Vec<u8>, Decode, SharedFetcher> as Backend>::Error>> + Send>>

A stream representing heartbeat signals.
Source§

type Codec = Decode

The codec used for serialization/deserialization of tasks.
Source§

type Context = SqlContext

Context associated with each task.
Source§

type Layer = Stack<LockTaskLayer, AcknowledgeLayer<PgAck>>

The type representing backend middleware layer.
Source§

fn heartbeat(&self, worker: &WorkerContext) -> Self::Beat

Returns a heartbeat stream for the given worker.
Source§

fn middleware(&self) -> Self::Layer

Returns the backend’s middleware layer.
Source§

fn poll(self, worker: &WorkerContext) -> Self::Stream

Polls the backend for tasks for the given worker.
Source§

impl<Args, Compact, Codec, Fetcher: Clone> Clone for PostgresStorage<Args, Compact, Codec, Fetcher>

Source§

fn clone(&self) -> Self

Returns a duplicate 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<Args: Sync, D, F> ConfigExt for PostgresStorage<Args, CompactType, D, F>
where PostgresStorage<Args, CompactType, D, F>: Backend<Context = SqlContext, Compact = CompactType, IdType = Ulid, Error = Error>,

Source§

fn get_queue(&self) -> Queue

Get the queue configuration
Source§

impl<Args, D, F> FetchById<Args> for PostgresStorage<Args, CompactType, D, F>
where PostgresStorage<Args, CompactType, D, F>: Backend<Context = PgContext, Compact = CompactType, IdType = Ulid, Error = Error>, D: Codec<Args, Compact = CompactType>, D::Error: Error + Send + Sync + 'static, Args: 'static,

Source§

fn fetch_by_id( &mut self, id: &TaskId<Ulid>, ) -> impl Future<Output = Result<Option<PgTask<Args>>, Self::Error>> + Send

Fetch a task by its unique identifier
Source§

impl<Args, D, F> ListAllTasks for PostgresStorage<Args, CompactType, D, F>
where PostgresStorage<Args, CompactType, D, F>: Backend<Context = SqlContext, Compact = CompactType, IdType = Ulid, Error = Error>,

Source§

fn list_all_tasks( &self, filter: &Filter, ) -> impl Future<Output = Result<Vec<Task<Self::Compact, Self::Context, Self::IdType>>, Self::Error>> + Send

List tasks matching the given filter in all queues
Source§

impl<Args, D, F> ListQueues for PostgresStorage<Args, CompactType, D, F>
where PostgresStorage<Args, CompactType, D, F>: Backend<Context = SqlContext, Compact = CompactType, IdType = Ulid, Error = Error>,

Source§

fn list_queues( &self, ) -> impl Future<Output = Result<Vec<QueueInfo>, Self::Error>> + Send

List all available queues in the backend
Source§

impl<Args, D, F> ListTasks<Args> for PostgresStorage<Args, CompactType, D, F>
where PostgresStorage<Args, CompactType, D, F>: Backend<Context = SqlContext, Compact = CompactType, IdType = Ulid, Error = Error>, D: Codec<Args, Compact = CompactType>, D::Error: Error + Send + Sync + 'static, Args: 'static,

Source§

fn list_tasks( &self, queue: &str, filter: &Filter, ) -> impl Future<Output = Result<Vec<PgTask<Args>>, Self::Error>> + Send

List tasks matching the given filter in the current queue
Source§

impl<Args: Sync, D, F> ListWorkers for PostgresStorage<Args, CompactType, D, F>
where PostgresStorage<Args, CompactType, D, F>: Backend<Context = SqlContext, Compact = CompactType, IdType = Ulid, Error = Error>,

Source§

fn list_workers( &self, queue: &str, ) -> impl Future<Output = Result<Vec<RunningWorker>, Self::Error>> + Send

List all registered workers in the current queue
Source§

fn list_all_workers( &self, ) -> impl Future<Output = Result<Vec<RunningWorker>, Self::Error>> + Send

List all registered workers in all queues
Source§

impl<Args, D, F> Metrics for PostgresStorage<Args, CompactType, D, F>
where PostgresStorage<Args, CompactType, D, F>: Backend<Context = SqlContext, Compact = CompactType, IdType = Ulid, Error = Error>,

Source§

fn global( &self, ) -> impl Future<Output = Result<Vec<Statistic>, Self::Error>> + Send

Collects and returns global statistics from the backend
Source§

fn fetch_by_queue( &self, queue_id: &str, ) -> impl Future<Output = Result<Vec<Statistic>, Self::Error>> + Send

Collects and returns statistics for a specific queue
Source§

impl<Args, Encode, Fetcher> Sink<Task<Vec<u8>, SqlContext, Ulid>> for PostgresStorage<Args, CompactType, Encode, Fetcher>
where Args: Unpin + Send + Sync + 'static, Fetcher: Unpin,

Source§

type Error = Error

The type of value produced by the sink when an error occurs.
Source§

fn poll_ready( self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>

Attempts to prepare the Sink to receive a value. Read more
Source§

fn start_send( self: Pin<&mut Self>, item: PgTask<CompactType>, ) -> Result<(), Self::Error>

Begin the process of sending a value to the sink. Each call to this function must be preceded by a successful call to poll_ready which returned Poll::Ready(Ok(())). Read more
Source§

fn poll_flush( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>

Flush any remaining output from this sink. Read more
Source§

fn poll_close( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>

Flush any remaining output and close this sink, if necessary. Read more
Source§

impl<O: 'static + Send, Args, F, Decode> WaitForCompletion<O> for PostgresStorage<Args, CompactType, Decode, F>
where PostgresStorage<Args, CompactType, Decode, F>: Backend<Context = SqlContext, Compact = CompactType, IdType = Ulid, Error = Error>, Result<O, String>: DeserializeOwned,

Source§

type ResultStream = Pin<Box<dyn Stream<Item = Result<TaskResult<O>, <PostgresStorage<Args, Vec<u8>, Decode, F> as Backend>::Error>> + Send>>

The result stream type yielding task results
Source§

fn wait_for( &self, task_ids: impl IntoIterator<Item = TaskId<Self::IdType>>, ) -> Self::ResultStream

Wait for multiple tasks to complete, yielding results as they become available
Source§

fn check_status( &self, task_ids: impl IntoIterator<Item = TaskId<Self::IdType>> + Send, ) -> impl Future<Output = Result<Vec<TaskResult<O>>, Self::Error>> + Send

Check current status of tasks without waiting
Source§

fn wait_for_single(&self, task_id: TaskId<Self::IdType>) -> Self::ResultStream

Wait for a single task to complete, yielding its result
Source§

impl<'pin, Args, Compact, Codec, Fetcher> Unpin for PostgresStorage<Args, Compact, Codec, Fetcher>
where PinnedFieldsOf<__PostgresStorage<'pin, Args, Compact, Codec, Fetcher>>: Unpin,

Auto Trait Implementations§

§

impl<Args, Compact, Codec, Fetcher> Freeze for PostgresStorage<Args, Compact, Codec, Fetcher>
where Fetcher: Freeze,

§

impl<Args, Compact = Vec<u8>, Codec = JsonCodec<Vec<u8>>, Fetcher = PgFetcher<Args, Compact, Codec>> !RefUnwindSafe for PostgresStorage<Args, Compact, Codec, Fetcher>

§

impl<Args, Compact, Codec, Fetcher> Send for PostgresStorage<Args, Compact, Codec, Fetcher>
where Fetcher: Send, Args: Send, Compact: Send, Codec: Send,

§

impl<Args, Compact, Codec, Fetcher> Sync for PostgresStorage<Args, Compact, Codec, Fetcher>
where Fetcher: Sync, Args: Sync, Compact: Sync, Codec: Sync,

§

impl<Args, Compact = Vec<u8>, Codec = JsonCodec<Vec<u8>>, Fetcher = PgFetcher<Args, Compact, Codec>> !UnwindSafe for PostgresStorage<Args, Compact, Codec, Fetcher>

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, Item> SinkExt<Item> for T
where T: Sink<Item> + ?Sized,

Source§

fn with<U, Fut, F, E>(self, f: F) -> With<Self, Item, U, Fut, F>
where F: FnMut(U) -> Fut, Fut: Future<Output = Result<Item, E>>, E: From<Self::Error>, Self: Sized,

Composes a function in front of the sink. Read more
Source§

fn with_flat_map<U, St, F>(self, f: F) -> WithFlatMap<Self, Item, U, St, F>
where F: FnMut(U) -> St, St: Stream<Item = Result<Item, Self::Error>>, Self: Sized,

Composes a function in front of the sink. Read more
Source§

fn sink_map_err<E, F>(self, f: F) -> SinkMapErr<Self, F>
where F: FnOnce(Self::Error) -> E, Self: Sized,

Transforms the error returned by the sink.
Source§

fn sink_err_into<E>(self) -> SinkErrInto<Self, Item, E>
where Self: Sized, Self::Error: Into<E>,

Map this sink’s error to a different error type using the Into trait. Read more
Source§

fn buffer(self, capacity: usize) -> Buffer<Self, Item>
where Self: Sized,

Adds a fixed-size buffer to the current sink. Read more
Source§

fn close(&mut self) -> Close<'_, Self, Item>
where Self: Unpin,

Close the sink.
Source§

fn fanout<Si>(self, other: Si) -> Fanout<Self, Si>
where Self: Sized, Item: Clone, Si: Sink<Item, Error = Self::Error>,

Fanout items to multiple sinks. Read more
Source§

fn flush(&mut self) -> Flush<'_, Self, Item>
where Self: Unpin,

Flush the sink, processing all pending items. Read more
Source§

fn send(&mut self, item: Item) -> Send<'_, Self, Item>
where Self: Unpin,

A future that completes after the given item has been fully processed into the sink, including flushing. Read more
Source§

fn feed(&mut self, item: Item) -> Feed<'_, Self, Item>
where Self: Unpin,

A future that completes after the given item has been received by the sink. Read more
Source§

fn send_all<'a, St>(&'a mut self, stream: &'a mut St) -> SendAll<'a, Self, St>
where St: TryStream<Ok = Item, Error = Self::Error> + Stream + Unpin + ?Sized, Self: Unpin,

A future that completes after the given stream has been fully processed into the sink, including flushing. Read more
Source§

fn left_sink<Si2>(self) -> Either<Self, Si2>
where Si2: Sink<Item, Error = Self::Error>, Self: Sized,

Wrap this sink in an Either sink, making it the left-hand variant of that Either. Read more
Source§

fn right_sink<Si1>(self) -> Either<Si1, Self>
where Si1: Sink<Item, Error = Self::Error>, Self: Sized,

Wrap this stream in an Either stream, making it the right-hand variant of that Either. Read more
Source§

fn poll_ready_unpin( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>
where Self: Unpin,

A convenience method for calling Sink::poll_ready on Unpin sink types.
Source§

fn start_send_unpin(&mut self, item: Item) -> Result<(), Self::Error>
where Self: Unpin,

A convenience method for calling Sink::start_send on Unpin sink types.
Source§

fn poll_flush_unpin( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>
where Self: Unpin,

A convenience method for calling Sink::poll_flush on Unpin sink types.
Source§

fn poll_close_unpin( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>
where Self: Unpin,

A convenience method for calling Sink::poll_close on Unpin sink types.
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> 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
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<B, Args> Expose<Args> for B
where B: Backend<Args = Args> + Metrics + ListWorkers + ListQueues + ListAllTasks + ListTasks<Args> + TaskSink<Args>,