pub struct PostgresFlowTaskQueue { /* private fields */ }Expand description
A3S ORM-backed PostgreSQL task queue for shared workers.
Pending and inflight tasks live in one table and are scoped by queue_name.
Leasing uses an atomic FOR UPDATE SKIP LOCKED CTE, so multiple workers can
lease concurrently without taking the same task. Heartbeats rotate fencing
tokens; stale acknowledgements cannot delete a task owned by another worker.
Implementations§
Source§impl PostgresFlowTaskQueue
impl PostgresFlowTaskQueue
Sourcepub async fn connect(database_url: impl AsRef<str>) -> Result<Self>
pub async fn connect(database_url: impl AsRef<str>) -> Result<Self>
Connects to PostgreSQL, migrates the schema, and uses the default queue.
Sourcepub async fn connect_verified(database_url: impl AsRef<str>) -> Result<Self>
pub async fn connect_verified(database_url: impl AsRef<str>) -> Result<Self>
Connects to PostgreSQL, verifies a separately migrated schema, and uses the default queue without acquiring DDL authority.
Sourcepub async fn connect_with_queue(
database_url: impl AsRef<str>,
queue_name: impl AsRef<str>,
) -> Result<Self>
pub async fn connect_with_queue( database_url: impl AsRef<str>, queue_name: impl AsRef<str>, ) -> Result<Self>
Connect with the ORM’s bounded non-TLS pool and run Flow migrations.
Production hosts that require TLS or custom pool controls should create
a configured PostgresExecutor and call
Self::from_executor_with_queue.
Sourcepub async fn connect_verified_with_queue(
database_url: impl AsRef<str>,
queue_name: impl AsRef<str>,
) -> Result<Self>
pub async fn connect_verified_with_queue( database_url: impl AsRef<str>, queue_name: impl AsRef<str>, ) -> Result<Self>
Connect with the ORM’s bounded non-TLS pool and verify a separately migrated Flow schema for the named queue.
Sourcepub async fn from_executor(executor: PostgresExecutor) -> Result<Self>
pub async fn from_executor(executor: PostgresExecutor) -> Result<Self>
Uses a configured executor, migrates the schema, and uses the default queue.
Sourcepub async fn from_executor_verified(executor: PostgresExecutor) -> Result<Self>
pub async fn from_executor_verified(executor: PostgresExecutor) -> Result<Self>
Uses a configured executor, verifies the Flow schema without mutation, and uses the default queue.
Sourcepub async fn from_executor_with_queue(
executor: PostgresExecutor,
queue_name: impl AsRef<str>,
) -> Result<Self>
pub async fn from_executor_with_queue( executor: PostgresExecutor, queue_name: impl AsRef<str>, ) -> Result<Self>
Uses a configured executor and migrates the named queue schema.
Sourcepub async fn from_executor_verified_with_queue(
executor: PostgresExecutor,
queue_name: impl AsRef<str>,
) -> Result<Self>
pub async fn from_executor_verified_with_queue( executor: PostgresExecutor, queue_name: impl AsRef<str>, ) -> Result<Self>
Uses a configured executor and verifies the complete Flow schema for a named queue without applying migrations.
Sourcepub fn executor(&self) -> &PostgresExecutor
pub fn executor(&self) -> &PostgresExecutor
Returns the configured A3S ORM executor.
Sourcepub fn queue_name(&self) -> &str
pub fn queue_name(&self) -> &str
Returns the logical queue name used to scope rows.
Sourcepub async fn inflight_len(&self) -> Result<usize>
pub async fn inflight_len(&self) -> Result<usize>
Returns the number of currently leased tasks.
Sourcepub async fn dead_letter_len(&self) -> Result<usize>
pub async fn dead_letter_len(&self) -> Result<usize>
Returns the number of dead-lettered tasks.
Sourcepub async fn dead_lettered_tasks(&self) -> Result<Vec<PostgresDeadLetteredTask>>
pub async fn dead_lettered_tasks(&self) -> Result<Vec<PostgresDeadLetteredTask>>
Loads dead-lettered tasks in durable insertion order.
Trait Implementations§
Source§impl Clone for PostgresFlowTaskQueue
impl Clone for PostgresFlowTaskQueue
Source§fn clone(&self) -> PostgresFlowTaskQueue
fn clone(&self) -> PostgresFlowTaskQueue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PostgresFlowTaskQueue
impl Debug for PostgresFlowTaskQueue
Source§impl FlowTaskQueue for PostgresFlowTaskQueue
impl FlowTaskQueue for PostgresFlowTaskQueue
Source§fn enqueue<'life0, 'async_trait>(
&'life0 self,
task: FlowTask,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn enqueue<'life0, 'async_trait>(
&'life0 self,
task: FlowTask,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn lease<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<FlowTaskLease>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn lease<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<FlowTaskLease>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn heartbeat<'life0, 'life1, 'async_trait>(
&'life0 self,
lease_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn heartbeat<'life0, 'life1, 'async_trait>(
&'life0 self,
lease_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn ack<'life0, 'life1, 'async_trait>(
&'life0 self,
lease_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn ack<'life0, 'life1, 'async_trait>(
&'life0 self,
lease_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn requeue_inflight<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn requeue_inflight<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn len<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn len<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl !RefUnwindSafe for PostgresFlowTaskQueue
impl !UnwindSafe for PostgresFlowTaskQueue
impl Freeze for PostgresFlowTaskQueue
impl Send for PostgresFlowTaskQueue
impl Sync for PostgresFlowTaskQueue
impl Unpin for PostgresFlowTaskQueue
impl UnsafeUnpin for PostgresFlowTaskQueue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FlowTaskDispatcher for Twhere
T: FlowTaskQueue + ?Sized,
impl<T> FlowTaskDispatcher for Twhere
T: FlowTaskQueue + ?Sized,
Source§fn dispatch<'life0, 'async_trait>(
&'life0 self,
task: FlowTask,
) -> Pin<Box<dyn Future<Output = Result<(), FlowError>> + Send + 'async_trait>>where
'life0: 'async_trait,
T: 'async_trait,
fn dispatch<'life0, 'async_trait>(
&'life0 self,
task: FlowTask,
) -> Pin<Box<dyn Future<Output = Result<(), FlowError>> + Send + 'async_trait>>where
'life0: 'async_trait,
T: 'async_trait,
Source§fn has_runtime_build_route(
&self,
required_build_id: Option<&RuntimeBuildId>,
) -> bool
fn has_runtime_build_route( &self, required_build_id: Option<&RuntimeBuildId>, ) -> bool
Source§fn ensure_runtime_build_route(
&self,
required_build_id: Option<&RuntimeBuildId>,
) -> Result<()>
fn ensure_runtime_build_route( &self, required_build_id: Option<&RuntimeBuildId>, ) -> Result<()>
Source§fn dispatch_for_runtime_build<'life0, 'life1, 'async_trait>(
&'life0 self,
required_build_id: Option<&'life1 RuntimeBuildId>,
task: FlowTask,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn dispatch_for_runtime_build<'life0, 'life1, 'async_trait>(
&'life0 self,
required_build_id: Option<&'life1 RuntimeBuildId>,
task: FlowTask,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
required_build_id. Read more