Skip to main content

PostgresResultBackend

Struct PostgresResultBackend 

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

PostgreSQL result backend implementation

Implementations§

Source§

impl PostgresResultBackend

Source

pub async fn new(database_url: &str) -> Result<Self>

Create a new PostgreSQL result backend

§Arguments
  • database_url - PostgreSQL connection string (e.g., “postgres://user:pass@localhost/db”)
Source

pub fn with_ttl_config(self, config: TaskTtlConfig) -> Self

Configure per-task-type TTL

Source

pub fn ttl_config(&self) -> &TaskTtlConfig

Get the TTL configuration

Source

pub fn ttl_config_mut(&mut self) -> &mut TaskTtlConfig

Get a mutable reference to the TTL configuration

Source

pub async fn migrate(&self) -> Result<()>

Run database migrations

Source

pub fn pool(&self) -> &PgPool

Get the underlying connection pool

Source

pub async fn cleanup_expired(&self) -> Result<usize>

Clean up expired results (returns number of deleted rows)

Trait Implementations§

Source§

impl Clone for PostgresResultBackend

Source§

fn clone(&self) -> PostgresResultBackend

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 ResultBackend for PostgresResultBackend

Source§

fn store_result<'life0, 'life1, 'async_trait>( &'life0 mut self, task_id: Uuid, meta: &'life1 TaskMeta, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store task result
Source§

fn get_result<'life0, 'async_trait>( &'life0 mut self, task_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<TaskMeta>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get task result
Source§

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

Delete task result
Source§

fn set_expiration<'life0, 'async_trait>( &'life0 mut self, task_id: Uuid, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set task result expiration
Source§

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

Chord: Initialize chord state
Source§

fn chord_complete_task<'life0, 'async_trait>( &'life0 mut self, chord_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Chord: Increment completion counter (returns total completed)
Source§

fn chord_get_state<'life0, 'async_trait>( &'life0 mut self, chord_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<ChordState>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Chord: Get chord state
Source§

fn store_results_batch<'life0, 'life1, 'async_trait>( &'life0 mut self, results: &'life1 [(Uuid, TaskMeta)], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store multiple task results (optimized with pipelining where supported)
Source§

fn get_results_batch<'life0, 'life1, 'async_trait>( &'life0 mut self, task_ids: &'life1 [Uuid], ) -> Pin<Box<dyn Future<Output = Result<Vec<Option<TaskMeta>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get multiple task results (optimized with pipelining where supported)
Source§

fn delete_results_batch<'life0, 'life1, 'async_trait>( &'life0 mut self, task_ids: &'life1 [Uuid], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete multiple task results (optimized with pipelining where supported)
Source§

fn chord_cancel<'life0, 'async_trait>( &'life0 mut self, chord_id: Uuid, reason: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<(), BackendError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Chord: Cancel a chord
Source§

fn chord_get_partial_results<'life0, 'async_trait>( &'life0 mut self, chord_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Vec<(Uuid, Option<TaskMeta>)>, BackendError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Chord: Get partial results for all tasks in chord Read more
Source§

fn chord_retry<'life0, 'async_trait>( &'life0 mut self, chord_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<bool, BackendError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Chord: Retry a failed chord Read more
Source§

fn store_versioned_result<'life0, 'life1, 'async_trait>( &'life0 mut self, task_id: Uuid, meta: &'life1 TaskMeta, ) -> Pin<Box<dyn Future<Output = Result<u32, BackendError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Store a versioned result Read more
Source§

fn get_result_version<'life0, 'async_trait>( &'life0 mut self, task_id: Uuid, _version: u32, ) -> Pin<Box<dyn Future<Output = Result<Option<TaskMeta>, BackendError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Get a specific version of a result Read more
Source§

fn set_progress<'life0, 'async_trait>( &'life0 mut self, task_id: Uuid, progress: ProgressInfo, ) -> Pin<Box<dyn Future<Output = Result<(), BackendError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Update task progress (for long-running tasks) Read more
Source§

fn get_progress<'life0, 'async_trait>( &'life0 mut self, task_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<ProgressInfo>, BackendError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Get task progress Read more
Source§

fn update_result_state<'life0, 'async_trait>( &'life0 mut self, task_id: Uuid, result: TaskResult, ) -> Pin<Box<dyn Future<Output = Result<(), BackendError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Update only the task result state (without changing other fields) Read more
Source§

fn update_worker<'life0, 'async_trait>( &'life0 mut self, task_id: Uuid, worker: String, ) -> Pin<Box<dyn Future<Output = Result<(), BackendError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Update only the worker field
Source§

fn mark_started<'life0, 'async_trait>( &'life0 mut self, task_id: Uuid, worker: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<(), BackendError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Mark task as started (updates state and timestamp)
Source§

fn mark_completed<'life0, 'async_trait>( &'life0 mut self, task_id: Uuid, result: TaskResult, ) -> Pin<Box<dyn Future<Output = Result<(), BackendError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Mark task as completed with result
Source§

fn get_results_paginated<'life0, 'life1, 'async_trait>( &'life0 mut self, task_ids: &'life1 [Uuid], page: usize, page_size: usize, ) -> Pin<Box<dyn Future<Output = Result<(Vec<Option<TaskMeta>>, usize, bool), BackendError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Get paginated task results Read more
Source§

impl ResultStore for PostgresResultBackend

Source§

fn store_result<'life0, 'async_trait>( &'life0 self, task_id: TaskId, result: TaskResultValue, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Store a task result
Source§

fn get_result<'life0, 'async_trait>( &'life0 self, task_id: TaskId, ) -> Pin<Box<dyn Future<Output = Result<Option<TaskResultValue>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieve a task result
Source§

fn get_state<'life0, 'async_trait>( &'life0 self, task_id: TaskId, ) -> Pin<Box<dyn Future<Output = Result<TaskState>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get task state
Source§

fn forget<'life0, 'async_trait>( &'life0 self, task_id: TaskId, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Delete a task result
Source§

fn has_result<'life0, 'async_trait>( &'life0 self, task_id: TaskId, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if a result exists

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