Skip to main content

Store

Struct Store 

Source
pub struct Store { /* private fields */ }

Implementations§

Source§

impl Store

Source

pub async fn load_parked( &self, cap: usize, rt: &Arc<Runtime>, skip: &HashSet<String>, ) -> Result<Vec<Arc<Process>>>

Load up to cap parked processes: durable rows in None state — a process was created while the resident set was full (see Cache::admit) or a never-started leftover from a crash — and never ran. Oldest first, so the restore pass refills slots FIFO. Parked rows are never resident, so skip only guards against a row whose pid is concurrently admitted (e.g. seeded by tests).

Source

pub async fn load_resumable( &self, cap: usize, rt: &Arc<Runtime>, skip: &HashSet<String>, ) -> Result<Vec<Arc<Process>>>

Load up to cap resumable processes: durable rows that were running when the engine crashed (Ready/Running/Pending), oldest first — the boot-resume working set. The number of matching rows beyond the cap is found with Self::count_resumable; the caller queues their pids for later slots. See Runtime::resume.

Source

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

Count durable rows that were in flight when the engine crashed (Ready/Running/Pending) — used at boot to detect processes that do not fit the resident cap and must wait in the resume queue.

Source

pub async fn load_proc( &self, pid: &str, rt: &Arc<Runtime>, ) -> Result<Option<Arc<Process>>>

Source

pub async fn remove_proc(&self, pid: &str) -> Result<bool>

Source

pub async fn enqueue_next_op(&self, pid: &str, tid: &str) -> Result<()>

but not yet run. Deduplicated per (pid, tid, type) — at most one in-flight record per operation, matching the previous Sign::NEXT_PENDING semantics. Queued on the store writer (FIFO) before the in-memory queue dispatch, after the task state write, so a Pending record always has a durable task behind it.

Source

pub async fn enqueue_exec_op(&self, pid: &str, tid: &str) -> Result<()>

Record a durable outbox entry for task execution. This is the disk overflow queue used when the in-memory scheduler queue is full.

Source

pub async fn enqueue_action_op( &self, pid: &str, tid: &str, event: &str, options: &str, ) -> Result<()>

Record a durable outbox entry for a client action (event + options). Deduplicated per (pid, tid, type), so it is not shadowed by the task’s in-flight next record (an interrupt act keeps its next op Pending while waiting for the client). Written before the action is applied so recovery can re-apply it when the crash happened before the task state write became durable.

Source

pub async fn load_pending_ops(&self) -> Result<Vec<Op>>

Load every outbox record that was not durably completed — the crash replay set. Read exhaustively — the engine replays exactly what this returns, so a page limit must never drop a record (id order, which is stable across restarts).

Source

pub async fn mark_op_dispatched( &self, pid: &str, tid: &str, type: &str, ) -> Result<()>

Mark a record as handed to the in-memory scheduler. Boot recovery still treats this state as replayable; periodic overflow recovery does not.

Source

pub async fn load_overflow_ops(&self, older_than_millis: i64) -> Result<Vec<Op>>

Load stale, not-yet-dispatched overflow records. Dispatched records are deliberately excluded while the engine is running: replaying them would duplicate work that is queued or executing in memory.

Source

pub async fn complete_ops(&self, pid: &str, tid: &str, type: &str) -> Result<()>

Close the in-flight outbox records of a task (Pending/Dispatched/ OverflowDone), filtered by operation type: a next close must not sweep away a concurrent client-action record of the same task (and vice versa). Must only be called after the operation’s effects (the task state write, including the NEXT_COMPLETE marker) were durably persisted — the writer FIFO order guarantees this.

Source

pub async fn mark_op_overflow( &self, pid: &str, tid: &str, type: &str, ) -> Result<()>

Mark a pending next record as overflowed to the durable scheduler disk queue after the bounded in-memory queue rejected it.

Source

pub async fn remove_ops(&self, pid: &str) -> Result<()>

Drop every outbox record of a process (used when the process is removed).

Source

pub async fn mark_delivered(&self, id: &str) -> Result<()>

Advance a stored delivery from Created to Delivered — the channel handler ran to completion, so the delivery succeeded. Only rows still Created move: a handler that acked (or was closed) while running must never be downgraded. The stored row is read under its document lock (Store::update_delivery), so a close or retry-pass write landing while the handler ran is seen — never overwritten by a stale Created.

Source

pub async fn set_delivery(&self, id: &str, status: DeliveryStatus) -> Result<()>

Ack one delivery row (by its delivery id): set its status.

Source

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

Re-send every error delivery row (reset to Created; the retry timer sends them to their own channels).

Source

pub async fn clear_error_deliveries(&self, pid: Option<String>) -> Result<()>

Delete error delivery rows: all of them or only those of one process.

Source

pub async fn resend_error_delivery( &self, delivery_id: &str, ) -> Result<Option<Delivery>>

Reset one error delivery row back to Created for redelivery. Returns the delivery when it was an error delivery and was reset, None otherwise.

Source

pub async fn clear_error_delivery(&self, delivery_id: &str) -> Result<bool>

Delete one error delivery row. Returns true when the row existed and was in error state and was deleted.

Source

pub async fn upsert_task(&self, task: &Arc<Task>) -> Result<()>

Source

pub async fn upsert_task_data(&self, data: &Task) -> Result<()>

Source

pub async fn upsert_task_vars(&self, task: &Arc<Task>) -> Result<()>

Persist one task scope’s vars row (data + sealed). Called by the persist path only for scopes whose vars actually changed.

Source

pub async fn persist_task_rows(&self, task: &Arc<Task>) -> Result<()>

Durable write of a task lifecycle row and every scope vars row that diverged: the task’s own row, then — walking the parent chain to the root — each ancestor whose vars changed since its last flush (the scope that owns an updated key, which update_data resolved at write time). A lifecycle-only transition (state/timing change, no data touched) writes just the one lifecycle row; scope vars rows are written exactly when the owning scope actually mutated. The dirty flags are cleared only after each row is durable, so a crash between mutations and the next persist loses nothing that the previous design would have kept.

Source

pub async fn mark_proc_complete( &self, pid: &str, end_time: i64, state: TaskState, ) -> Result<()>

Source

pub async fn upsert_proc(&self, proc: &Arc<Process>) -> Result<()>

Source§

impl Store

Source

pub fn new(kv: Arc<dyn KvStore>) -> Self

Source

pub fn tasks(&self) -> Arc<dyn DbCollection<Item = Task>>

Source

pub fn procs(&self) -> Arc<dyn DbCollection<Item = Proc>>

Source

pub fn vars(&self) -> Arc<dyn DbCollection<Item = TaskVars>>

Source

pub fn packages(&self) -> Arc<dyn DbCollection<Item = Package>>

Source

pub fn models(&self) -> Arc<dyn DbCollection<Item = Model>>

Source

pub fn messages(&self) -> Arc<dyn DbCollection<Item = Message>>

Source

pub fn deliveries(&self) -> Arc<dyn DbCollection<Item = Delivery>>

Source

pub fn events(&self) -> Arc<dyn DbCollection<Item = Event>>

Source

pub fn ops(&self) -> Arc<dyn DbCollection<Item = Op>>

Source

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

Rebuild all collection index entries from stored data documents.

Run once after upgrading to a version whose index-key value encoding changed (see KvCollection::rebuild_index); calling it repeatedly is harmless (idempotent rewrite).

Source

pub async fn publish(&self, pack: &Package) -> Result<bool>

Source

pub async fn deploy( &self, model: &Workflow, view: Option<&JsonValue>, ) -> Result<bool>

Source

pub async fn rm_model(&self, id: &str) -> Result<bool>

Atomically remove a model and every trigger (events) row of it in one batch: a mid-removal failure can no longer leave stale trigger rows (or a half-cleared event set) behind. Removing an absent model is a no-op that still returns true.

Source

pub async fn with_no_response_deliveries( &self, timeout_millis: i64, max_delivery_retry_times: i32, ) -> Result<Vec<Delivery>>

Collect deliveries with no response: re-arm the ones that were handed over but never acked (Delivered — as well as Created rows that were never successfully dispatched) and mark the ones that exceeded max_delivery_retry_times as errors. Returns every re-armed delivery (the caller re-sends them to their own channels).

The candidate page is a hint, not the decision: every row is re-read under its document lock and acted on from that stored state, so a row the engine closed, the client acked or a manual resend re-armed while this pass runs is left alone instead of being overwritten by a stale read and re-sent after the message already settled.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Store

§

impl !UnwindSafe for Store

§

impl Freeze for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> ParallelSend for T
where T: Send,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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