Skip to main content

Store

Struct Store 

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

Implementations§

Source§

impl Store

Source

pub fn create_instance( &self, name: &str, substrate: &str, definition: &str, source_overrides: &BTreeMap<String, String>, definition_dir: &str, dirty: bool, ) -> Result<InstanceRecord, StateError>

Create an instance record. Names are unique across substrates: a clash is an error naming the existing substrate, not a sibling. The UNIQUE PRIMARY KEY enforces this on both backends — fleet-wide when the remote plane is configured.

Source

pub fn instance(&self, name: &str) -> Result<Option<InstanceRecord>, StateError>

Source

pub fn instances(&self) -> Result<Vec<InstanceRecord>, StateError>

Source

pub fn tombstone_instance(&self, name: &str) -> Result<(), StateError>

Teardown leaves a tombstone, not amnesia (§2).

Source

pub fn revive_instance( &self, name: &str, definition: &str, source_overrides: &BTreeMap<String, String>, dirty: bool, ) -> Result<(), StateError>

up on a tombstone is a fresh birth under the old name: new definition snapshot, active status, empty journal.

Source

pub fn update_source_overrides( &self, name: &str, source_overrides: &BTreeMap<String, String>, ) -> Result<(), StateError>

Record per-invocation overrides on resume (an explicit, recorded choice — never ambient discovery).

Source

pub fn update_dirty(&self, name: &str, dirty: bool) -> Result<(), StateError>

Record per-invocation dirty mode on resume.

Source§

impl Store

Source

pub fn record_checkpoint( &self, instance: &str, step_id: &str, resource_kind: &str, resource_id: &str, payload: &str, ) -> Result<(), StateError>

Source

pub fn checkpoint( &self, instance: &str, step_id: &str, ) -> Result<Option<Checkpoint>, StateError>

Source

pub fn checkpoints(&self, instance: &str) -> Result<Vec<Checkpoint>, StateError>

All checkpoints for an instance in recording order — what an interrupted down must hunt down.

Source

pub fn remove_checkpoint( &self, instance: &str, step_id: &str, ) -> Result<(), StateError>

Remove one checkpoint after its resource is verifiably gone.

Source§

impl Store

Source

pub fn renew_lease( &self, instance: &str, duration: Duration, ) -> Result<Lease, StateError>

Set (or reset) the lease to its full duration from now.

Source

pub fn renew_lease_at_recorded_duration( &self, instance: &str, ) -> Result<(), StateError>

Renew at the recorded duration (the start-of-verb renewal: the duration was consented to at creation).

Source

pub fn lease(&self, instance: &str) -> Result<Option<Lease>, StateError>

Source

pub fn delete_lease(&self, instance: &str) -> Result<(), StateError>

A tombstoned instance has no lease left to enforce.

Source

pub fn expired_instances(&self) -> Result<Vec<String>, StateError>

Active instances whose lease has expired — the reaper’s worklist.

Source§

impl Store

Source

pub fn claim_lock( &self, instance: &str, operation: &str, ) -> Result<LockClaim, StateError>

Claim the operation lock for instance, taking over a dead (same-host) or stale (foreign-host) holder’s claim. Fails fast with a stable code if a live holder has it — agents retry stuck commands, so overlapping operations are an expected event.

Source

pub fn release_lock(&self, claim: &LockClaim) -> Result<(), StateError>

Release a claim. Only the recorded holder’s release deletes the row, so a stale guard cannot release a successor’s lock.

Source

pub fn lock_holder_alive(&self, instance: &str) -> Result<bool, StateError>

Whether instance is currently mid-operation under a live holder — the reaper must never reap such an instance (§6). A foreign-host holder is treated as live (its PID is unprobeable here) until the lease/staleness machinery resolves it.

Source§

impl Store

Source

pub fn record_reap_failure( &self, instance: &str, error: &str, ) -> Result<(), StateError>

Record a failed reap, advancing the backoff. attempts increments; next_retry_at is now + the doubled delay.

Source

pub fn clear_reap_failure(&self, instance: &str) -> Result<(), StateError>

Clear an instance’s reap-failure record — a successful reap or a successful manual down calls this through the engine.

Source

pub fn reap_attempt( &self, instance: &str, ) -> Result<Option<ReapAttempt>, StateError>

Source

pub fn gc_due_tombstones(&self) -> Result<Vec<String>, StateError>

Tombstoned instances whose GC window has elapsed — the reaper deletes the row (FK cascade cleans leases/locks/checkpoints) and removes the logs dir (D14).

Source

pub fn delete_instance(&self, instance: &str) -> Result<(), StateError>

Delete an instance row outright (the GC step). FK cascade removes its leases, locks, checkpoints, and reap-attempt row.

Source§

impl Store

Source

pub fn open(path: &Path) -> Result<Self, StateError>

Open (creating and migrating as needed) a local file store.

Source

pub fn open_remote(url: &str, token: &str) -> Result<Self, StateError>

Open against a remote libsql primary (the fleet plane).

Source

pub fn open_configured() -> Result<Self, StateError>

Route by config: STACKLESS_STATE_URL (+ STACKLESS_STATE_TOKEN) selects the remote fleet plane; absent, the local default file.

Source

pub fn open_with_paths(paths: &Paths) -> Result<Self, StateError>

Like Self::open_configured, but uses paths.db_path() for the local backend when no remote URL is set.

Source

pub fn state_dir() -> PathBuf

$XDG_STATE_HOME/stackless, falling back to ~/.local/state/stackless.

Source

pub fn default_path() -> PathBuf

The default per-user location: $XDG_STATE_HOME/stackless/state.db, falling back to ~/.local/state/stackless/state.db.

Source

pub fn now_secs() -> i64

The shared clock, for callers outside the store (the reaper’s tick). Same value Store::now writes into rows.

Trait Implementations§

Source§

impl Debug for Store

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Store

§

impl !RefUnwindSafe for Store

§

impl !Sync for Store

§

impl !UnwindSafe for Store

§

impl Send 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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