Skip to main content

InMemoryBackend

Struct InMemoryBackend 

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

In-memory backend that stores snapshots in a HashMap.

This implementation is thread-safe and suitable for testing. For production use, consider implementing the persistence traits for a more durable storage backend (Redis, PostgreSQL, etc.).

Implementations§

Source§

impl InMemoryBackend

Source

pub fn new() -> Self

Create a new in-memory backend.

Trait Implementations§

Source§

impl Clone for InMemoryBackend

Source§

fn clone(&self) -> InMemoryBackend

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 Default for InMemoryBackend

Source§

fn default() -> InMemoryBackend

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

impl SignalStore for InMemoryBackend

Source§

async fn store_signal( &self, instance_id: &str, kind: SignalKind, request: SignalRequest, ) -> Result<(), BackendError>

Store a signal (cancel or pause) for a workflow instance.
Source§

async fn get_signal( &self, instance_id: &str, kind: SignalKind, ) -> Result<Option<SignalRequest>, BackendError>

Get the pending signal of the given kind, if any.
Source§

async fn clear_signal( &self, instance_id: &str, kind: SignalKind, ) -> Result<(), BackendError>

Clear the signal of the given kind.
Source§

async fn send_event( &self, instance_id: &str, signal_name: &str, payload: Bytes, ) -> Result<(), BackendError>

Send an external event to a workflow instance. Read more
Source§

async fn consume_event( &self, instance_id: &str, signal_name: &str, ) -> Result<Option<Bytes>, BackendError>

Consume the oldest buffered event for the given signal name, if any. Read more
Source§

async fn check_and_cancel( &self, instance_id: &str, interrupted_at_task: Option<&str>, ) -> Result<bool, BackendError>

Atomically check for cancellation and transition to cancelled state. Read more
Source§

async fn check_and_pause(&self, instance_id: &str) -> Result<bool, BackendError>

Atomically check for a pause request and transition to paused state. Read more
Source§

async fn unpause( &self, instance_id: &str, ) -> Result<WorkflowSnapshot, BackendError>

Transition a paused workflow back to in-progress and return the updated snapshot.
Source§

impl SnapshotStore for InMemoryBackend

Source§

async fn save_snapshot( &self, snapshot: &WorkflowSnapshot, ) -> Result<(), BackendError>

Save a workflow snapshot. Read more
Source§

async fn save_task_result( &self, instance_id: &str, task_id: &str, output: Bytes, ) -> Result<(), BackendError>

Save a single task result atomically. Read more
Source§

async fn load_snapshot( &self, instance_id: &str, ) -> Result<WorkflowSnapshot, BackendError>

Load a workflow snapshot by instance ID.
Source§

async fn delete_snapshot(&self, instance_id: &str) -> Result<(), BackendError>

Delete a workflow snapshot.
Source§

async fn list_snapshots(&self) -> Result<Vec<String>, BackendError>

List all snapshot instance IDs.
Source§

impl TaskClaimStore for InMemoryBackend

Source§

async fn claim_task( &self, instance_id: &str, task_id: &str, worker_id: &str, ttl: Option<Duration>, ) -> Result<Option<TaskClaim>, BackendError>

Claim a task for execution by a worker node. Read more
Source§

async fn release_task_claim( &self, instance_id: &str, task_id: &str, worker_id: &str, ) -> Result<(), BackendError>

Release a task claim.
Source§

async fn extend_task_claim( &self, instance_id: &str, task_id: &str, worker_id: &str, additional_duration: Duration, ) -> Result<(), BackendError>

Extend a task claim’s expiration time.
Source§

async fn find_available_tasks( &self, worker_id: &str, limit: usize, ) -> Result<Vec<AvailableTask>, BackendError>

Find available tasks across all workflow instances.

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