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§
Trait Implementations§
Source§impl Clone for InMemoryBackend
impl Clone for InMemoryBackend
Source§fn clone(&self) -> InMemoryBackend
fn clone(&self) -> InMemoryBackend
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for InMemoryBackend
impl Default for InMemoryBackend
Source§fn default() -> InMemoryBackend
fn default() -> InMemoryBackend
Returns the “default value” for a type. Read more
Source§impl SignalStore for InMemoryBackend
impl SignalStore for InMemoryBackend
Source§async fn store_signal(
&self,
instance_id: &str,
kind: SignalKind,
request: SignalRequest,
) -> Result<(), BackendError>
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>
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>
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>
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>
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>
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>
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>
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
impl SnapshotStore for InMemoryBackend
Source§async fn save_snapshot(
&self,
snapshot: &WorkflowSnapshot,
) -> Result<(), BackendError>
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>
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>
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>
async fn delete_snapshot(&self, instance_id: &str) -> Result<(), BackendError>
Delete a workflow snapshot.
Source§async fn list_snapshots(&self) -> Result<Vec<String>, BackendError>
async fn list_snapshots(&self) -> Result<Vec<String>, BackendError>
List all snapshot instance IDs.
Source§impl TaskClaimStore for InMemoryBackend
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>
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>
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>
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>
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§
impl Freeze for InMemoryBackend
impl RefUnwindSafe for InMemoryBackend
impl Send for InMemoryBackend
impl Sync for InMemoryBackend
impl Unpin for InMemoryBackend
impl UnsafeUnpin for InMemoryBackend
impl UnwindSafe for InMemoryBackend
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
Mutably borrows from an owned value. Read more