Skip to main content

MemoryBackend

Struct MemoryBackend 

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

Thread-safe in-memory implementation of StorageBackend.

Ideal for unit testing, ephemeral workloads, and local development without external database servers.

Implementations§

Source§

impl MemoryBackend

Source

pub fn new() -> Self

Creates a new, empty MemoryBackend.

Source

pub fn clear(&self)

Resets and clears all stored jobs and attempt history.

Trait Implementations§

Source§

impl Clone for MemoryBackend

Source§

fn clone(&self) -> MemoryBackend

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MemoryBackend

Source§

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

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

impl Default for MemoryBackend

Source§

fn default() -> MemoryBackend

Returns the “default value” for a type. Read more
Source§

impl StorageBackend for MemoryBackend

Source§

fn as_stream(&self) -> Option<&dyn StreamBackend>

Returns reference to StreamBackend if supported by this storage implementation.
Source§

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

Executes backend schema migrations or setup steps.
Source§

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

Performs a health check to verify backend connectivity and readiness.
Source§

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

Enqueues a new job into the backend queue.
Source§

fn subscribe<'life0, 'life1, 'async_trait>( &'life0 self, queue: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<NotificationStream>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Subscribes to job enqueue notification events for a specific queue.
Source§

fn lease_jobs_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, queue: &'life1 str, worker_id: &'life2 str, lease_seconds: i64, batch_size: i64, ) -> Pin<Box<dyn Future<Output = Result<Vec<Job>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Leases up to batch_size runnable jobs for a specified worker ID.
Source§

fn lease_jobs_batch_with_ordering<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, queue: &'life1 str, worker_id: &'life2 str, lease_seconds: i64, batch_size: i64, ordering: QueueOrdering, ) -> Pin<Box<dyn Future<Output = Result<Vec<Job>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Leases up to batch_size runnable jobs with specified queue ordering preference (QueueOrdering).
Source§

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

Reaps expired locks from inactive workers, resetting their status back to queued.
Source§

fn start_attempts_batch<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, _dataset_ids: &'life1 [String], job_ids: &'life2 [Uuid], worker_id: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<(Uuid, Uuid, i32)>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Starts job execution attempt records, returning (job_id, attempt_id, attempt_number) tuples.
Source§

fn mark_succeeded<'life0, 'life1, 'async_trait>( &'life0 self, job_id: Uuid, attempt_id: Uuid, _worker_id: &'life1 str, latency_ms: i32, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Marks a single job execution attempt as succeeded.
Source§

fn mark_succeeded_batch<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, _dataset_id: &'life1 str, updates: &'life2 [(Uuid, Uuid, i32)], worker_id: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Marks a batch of job execution attempts as succeeded.
Source§

fn reschedule_for_retry<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, job_id: Uuid, attempt_id: Uuid, _worker_id: &'life1 str, latency_ms: i32, next_run_at: DateTime<Utc>, error_code: &'life2 str, error_message: &'life3 str, _attempt_no: i32, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Records a failed attempt and reschedules the job for a future retry attempt.
Source§

fn mark_dlq<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, job_id: Uuid, attempt_id: Uuid, _worker_id: &'life1 str, latency_ms: i32, reason_code: &'life2 str, error_code: &'life3 str, error_message: &'life4 str, _attempt_no: i32, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Records a failed attempt and transitions the job to the Dead-Letter Queue (DLQ).
Source§

fn archive_succeeded_older_than<'life0, 'async_trait>( &'life0 self, cutoff: DateTime<Utc>, limit: i64, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Moves succeeded jobs older than cutoff into an archive table or storage location.
Source§

fn delete_history_for_succeeded_older_than<'life0, 'async_trait>( &'life0 self, cutoff: DateTime<Utc>, limit: i64, ) -> Pin<Box<dyn Future<Output = Result<(u64, u64)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Prunes attempt audit logs and decision records for succeeded jobs older than cutoff.
Source§

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

Performs database maintenance (e.g., VACUUM ANALYZE in Postgres, PRAGMA incremental_vacuum in SQLite).
Source§

fn extend_lease<'life0, 'life1, 'async_trait>( &'life0 self, job_id: Uuid, worker_id: &'life1 str, lease_seconds: i64, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Extends the lease lock expiration for an in-flight running job. Returns true if the lease was extended, false if the job lock was lost or reaped.
Source§

fn get_job<'life0, 'async_trait>( &'life0 self, job_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<Job>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetches a single job record by ID.
Source§

fn list_jobs<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, queue: Option<&'life1 str>, status: Option<&'life2 str>, limit: i64, _cursor_created_at: Option<DateTime<Utc>>, _cursor_id: Option<Uuid>, ) -> Pin<Box<dyn Future<Output = Result<Vec<JobListItem>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Fetches a list of jobs matching filters with cursor pagination.
Source§

fn replay_job<'life0, 'life1, 'async_trait>( &'life0 self, job_id: Uuid, override_queue: Option<&'life1 str>, override_run_at: Option<DateTime<Utc>>, ) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Atomically replays a job by ID into the queue.
Source§

fn dequeue_and_lease<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, queue: &'life1 str, worker_id: &'life2 str, lease_seconds: i64, batch_size: i64, ) -> Pin<Box<dyn Future<Output = Result<Vec<Job>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Dequeues and leases up to batch_size runnable jobs (alias for lease_jobs_batch).
Source§

fn complete_job<'life0, 'life1, 'async_trait>( &'life0 self, job_id: Uuid, attempt_id: Uuid, worker_id: &'life1 str, latency_ms: i32, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Marks a job attempt as completed (alias for mark_succeeded).
Source§

fn retry_job<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, job_id: Uuid, attempt_id: Uuid, worker_id: &'life1 str, latency_ms: i32, next_run_at: DateTime<Utc>, error_code: &'life2 str, error_message: &'life3 str, attempt_no: i32, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Reschedules a job for retry (alias for reschedule_for_retry).
Source§

fn fail_job<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, job_id: Uuid, attempt_id: Uuid, worker_id: &'life1 str, latency_ms: i32, reason_code: &'life2 str, error_code: &'life3 str, error_message: &'life4 str, attempt_no: i32, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Moves a job to DLQ on failure (alias for mark_dlq).
Source§

impl StreamBackend for MemoryBackend

Source§

fn publish<'life0, 'life1, 'async_trait>( &'life0 self, stream: &'life1 str, event: NewEvent, ) -> Pin<Box<dyn Future<Output = Result<i64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Appends a new event to the specified stream log, returning its assigned sequence number.
Source§

fn subscribe_stream<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, stream: &'life1 str, _consumer_group: &'life2 str, _last_seq: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<NotificationStream>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Subscribes to notification events when new entries are appended to a stream.
Source§

fn ack<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, stream: &'life1 str, consumer_group: &'life2 str, seq: i64, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Acknowledges event processing up to seq for a consumer group on a stream log.
Source§

fn read_events<'life0, 'life1, 'async_trait>( &'life0 self, stream: &'life1 str, after_seq: i64, limit: i64, ) -> Pin<Box<dyn Future<Output = Result<Vec<Event>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Reads events from a stream with sequence numbers strictly greater than after_seq.
Source§

fn consumer_group_info<'life0, 'life1, 'async_trait>( &'life0 self, stream: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<ConsumerGroupStatus>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetches consumer group offset status for a stream log.

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