pub struct AsyncQueue<Tls>where
    Tls: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static,
    <Tls as MakeTlsConnect<Socket>>::Stream: Send + Sync,
    <Tls as MakeTlsConnect<Socket>>::TlsConnect: Send,
    <<Tls as MakeTlsConnect<Socket>>::TlsConnect as TlsConnect<Socket>>::Future: Send,{ /* private fields */ }
Expand description

An async queue that can be used to enqueue tasks. It uses a PostgreSQL storage. It must be connected to perform any operation. To connect an AsyncQueue to PostgreSQL database call the connect method. A Queue can be created with the TypedBuilder.

     let mut queue = AsyncQueue::builder()
         .uri("postgres://postgres:postgres@localhost/fang")
         .max_pool_size(max_pool_size)
         .build();

Implementations§

source§

impl<Tls> AsyncQueue<Tls>where Tls: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static, <Tls as MakeTlsConnect<Socket>>::Stream: Send + Sync, <Tls as MakeTlsConnect<Socket>>::TlsConnect: Send, <<Tls as MakeTlsConnect<Socket>>::TlsConnect as TlsConnect<Socket>>::Future: Send,

source

pub fn builder() -> AsyncQueueBuilder<Tls, ((), ())>

Create a builder for building AsyncQueue. On the builder, call .uri(...), .max_pool_size(...) to set the values of the fields. Finally, call .build() to create the instance of AsyncQueue.

source§

impl<Tls> AsyncQueue<Tls>where Tls: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static, <Tls as MakeTlsConnect<Socket>>::Stream: Send + Sync, <Tls as MakeTlsConnect<Socket>>::TlsConnect: Send, <<Tls as MakeTlsConnect<Socket>>::TlsConnect as TlsConnect<Socket>>::Future: Send,

source

pub fn check_if_connection(&self) -> Result<(), AsyncQueueError>

Check if the connection with db is established

source

pub async fn connect(&mut self, tls: Tls) -> Result<(), AsyncQueueError>

Connect to the db if not connected

Trait Implementations§

source§

impl<Tls> AsyncQueueable for AsyncQueue<Tls>where Tls: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static, <Tls as MakeTlsConnect<Socket>>::Stream: Send + Sync, <Tls as MakeTlsConnect<Socket>>::TlsConnect: Send, <<Tls as MakeTlsConnect<Socket>>::TlsConnect as TlsConnect<Socket>>::Future: Send,

source§

fn find_task_by_id<'life0, 'async_trait>( &'life0 mut self, id: Uuid ) -> Pin<Box<dyn Future<Output = Result<Task, AsyncQueueError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Retrieve a task from storage by its id.
source§

fn fetch_and_touch_task<'life0, 'async_trait>( &'life0 mut self, task_type: Option<String> ) -> Pin<Box<dyn Future<Output = Result<Option<Task>, AsyncQueueError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

This method should retrieve one task of the task_type type. If task_type is None it will try to fetch a task of the type common. After fetching it should update the state of the task to FangTaskState::InProgress.
source§

fn insert_task<'life0, 'life1, 'async_trait>( &'life0 mut self, task: &'life1 dyn AsyncRunnable ) -> Pin<Box<dyn Future<Output = Result<Task, AsyncQueueError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Enqueue a task to the queue, The task will be executed as soon as possible by the worker of the same type created by an AsyncWorkerPool.
source§

fn schedule_task<'life0, 'life1, 'async_trait>( &'life0 mut self, task: &'life1 dyn AsyncRunnable ) -> Pin<Box<dyn Future<Output = Result<Task, AsyncQueueError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Schedule a task.
source§

fn remove_all_tasks<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Result<u64, AsyncQueueError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

The method will remove all tasks from the queue
source§

fn remove_all_scheduled_tasks<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Result<u64, AsyncQueueError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Remove all tasks that are scheduled in the future.
source§

fn remove_task<'life0, 'async_trait>( &'life0 mut self, id: Uuid ) -> Pin<Box<dyn Future<Output = Result<u64, AsyncQueueError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Remove a task by its id.
source§

fn remove_task_by_metadata<'life0, 'life1, 'async_trait>( &'life0 mut self, task: &'life1 dyn AsyncRunnable ) -> Pin<Box<dyn Future<Output = Result<u64, AsyncQueueError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove a task by its metadata (struct fields values)
source§

fn remove_tasks_type<'life0, 'life1, 'async_trait>( &'life0 mut self, task_type: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<u64, AsyncQueueError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Removes all tasks that have the specified task_type.
source§

fn update_task_state<'life0, 'async_trait>( &'life0 mut self, task: Task, state: FangTaskState ) -> Pin<Box<dyn Future<Output = Result<Task, AsyncQueueError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Update the state field of the specified task See the FangTaskState enum for possible states.
source§

fn fail_task<'life0, 'life1, 'async_trait>( &'life0 mut self, task: Task, error_message: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<Task, AsyncQueueError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update the state of a task to FangTaskState::Failed and set an error_message.
source§

fn schedule_retry<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, task: &'life1 Task, backoff_seconds: u32, error: &'life2 str ) -> Pin<Box<dyn Future<Output = Result<Task, AsyncQueueError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

source§

impl<Tls> Clone for AsyncQueue<Tls>where Tls: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static + Clone, <Tls as MakeTlsConnect<Socket>>::Stream: Send + Sync, <Tls as MakeTlsConnect<Socket>>::TlsConnect: Send, <<Tls as MakeTlsConnect<Socket>>::TlsConnect as TlsConnect<Socket>>::Future: Send,

source§

fn clone(&self) -> AsyncQueue<Tls>

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<Tls> Debug for AsyncQueue<Tls>where Tls: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static + Debug, <Tls as MakeTlsConnect<Socket>>::Stream: Send + Sync, <Tls as MakeTlsConnect<Socket>>::TlsConnect: Send, <<Tls as MakeTlsConnect<Socket>>::TlsConnect as TlsConnect<Socket>>::Future: Send,

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Tls> !RefUnwindSafe for AsyncQueue<Tls>

§

impl<Tls> Send for AsyncQueue<Tls>

§

impl<Tls> Sync for AsyncQueue<Tls>

§

impl<Tls> Unpin for AsyncQueue<Tls>

§

impl<Tls> !UnwindSafe for AsyncQueue<Tls>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> IntoSql for T

source§

fn into_sql<T>(self) -> Self::Expressionwhere Self: AsExpression<T> + Sized, T: SqlType + TypedExpressionType,

Convert self to an expression for Diesel’s query builder. Read more
source§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere 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 Twhere 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 Twhere 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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

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