pub struct SqliteAgentStore { /* private fields */ }Expand description
Cloneable handle to the single-owner SQLite Tokio actor implementing
allen_store::AgentStore.
Cloning this handle shares the same bounded command channel to the single actor task. When all clones are dropped, the channel closes and the actor exits cleanly after finishing any in-flight transaction.
Implementations§
Source§impl SqliteAgentStore
impl SqliteAgentStore
Sourcepub async fn connect_and_migrate(
config: SqliteStoreConfig,
) -> Result<Self, StoreError>
pub async fn connect_and_migrate( config: SqliteStoreConfig, ) -> Result<Self, StoreError>
Opens the SQLite database described by config, spawns the single-owner Tokio
actor, and verifies or applies all append-only SQL migrations before returning.
Creates missing parent directories for file-backed paths, enables foreign keys and
PRAGMA synchronous = FULL, and verifies SHA-256 checksums for every previously
applied migration in schema_migrations.
§Errors
Returns:
StoreError::SchemaDriftif an already-applied migration’s name or SHA-256 checksum differs from the compiled migration set.StoreError::Backendif creating parent directories, opening SQLite, applying migrations, or initializing the actor task fails.
§Examples
use allen_store_sqlite::{SqliteAgentStore, SqliteStoreConfig};
let store = SqliteAgentStore::connect_and_migrate(
SqliteStoreConfig::try_new(":memory:").unwrap(),
)
.await
.unwrap();
assert!(format!("{store:?}").contains("SqliteAgentStore"));Trait Implementations§
Source§impl Clone for SqliteAgentStore
impl Clone for SqliteAgentStore
Source§impl CommandStore for SqliteAgentStore
impl CommandStore for SqliteAgentStore
Source§fn lookup_receipt<'a>(
&'a self,
tenant_id: &'a TenantId,
session_id: &'a SessionId,
command_id: &'a CommandId,
) -> BoxFuture<'a, Result<Option<CommandReceipt>, StoreError>>
fn lookup_receipt<'a>( &'a self, tenant_id: &'a TenantId, session_id: &'a SessionId, command_id: &'a CommandId, ) -> BoxFuture<'a, Result<Option<CommandReceipt>, StoreError>>
Source§fn commit_step<'a>(
&'a self,
lease: &'a LeaseToken,
commit: StepCommit,
) -> BoxFuture<'a, Result<StepCommitResult, StoreError>>
fn commit_step<'a>( &'a self, lease: &'a LeaseToken, commit: StepCommit, ) -> BoxFuture<'a, Result<StepCommitResult, StoreError>>
Atomically verifies
lease and commit.expected_revision, then persists all entries,
leaf pointer updates, epoch bumps, effect journal mutations, spend entries, and the
optional command receipt in a single transaction. Read moreSource§fn list_unknown_effects<'a>(
&'a self,
tenant_id: &'a TenantId,
run_id: &'a RunId,
) -> BoxFuture<'a, Result<Vec<EffectRecord>, StoreError>>
fn list_unknown_effects<'a>( &'a self, tenant_id: &'a TenantId, run_id: &'a RunId, ) -> BoxFuture<'a, Result<Vec<EffectRecord>, StoreError>>
Source§fn list_claimed_effects<'a>(
&'a self,
tenant_id: &'a TenantId,
run_id: &'a RunId,
) -> BoxFuture<'a, Result<Vec<EffectRecord>, StoreError>>
fn list_claimed_effects<'a>( &'a self, tenant_id: &'a TenantId, run_id: &'a RunId, ) -> BoxFuture<'a, Result<Vec<EffectRecord>, StoreError>>
Source§impl Debug for SqliteAgentStore
impl Debug for SqliteAgentStore
Source§impl LeaseStore for SqliteAgentStore
impl LeaseStore for SqliteAgentStore
Source§fn enqueue_run<'a>(
&'a self,
tenant_id: &'a TenantId,
session_id: &'a SessionId,
run_id: &'a RunId,
pool_name: &'a PoolName,
) -> BoxFuture<'a, Result<(), StoreError>>
fn enqueue_run<'a>( &'a self, tenant_id: &'a TenantId, session_id: &'a SessionId, run_id: &'a RunId, pool_name: &'a PoolName, ) -> BoxFuture<'a, Result<(), StoreError>>
Source§fn acquire_session_lease<'a>(
&'a self,
tenant_id: &'a TenantId,
session_id: &'a SessionId,
owner_id: &'a OwnerId,
ttl: Duration,
) -> BoxFuture<'a, Result<LeaseToken, StoreError>>
fn acquire_session_lease<'a>( &'a self, tenant_id: &'a TenantId, session_id: &'a SessionId, owner_id: &'a OwnerId, ttl: Duration, ) -> BoxFuture<'a, Result<LeaseToken, StoreError>>
Acquires or supersedes an exclusive lease on an interactive session for
owner_id. Read moreSource§fn claim_queued_run<'a>(
&'a self,
owner_id: &'a OwnerId,
pool_name: &'a PoolName,
ttl: Duration,
) -> BoxFuture<'a, Result<Option<LeaseToken>, StoreError>>
fn claim_queued_run<'a>( &'a self, owner_id: &'a OwnerId, pool_name: &'a PoolName, ttl: Duration, ) -> BoxFuture<'a, Result<Option<LeaseToken>, StoreError>>
Atomically claims at most one
Queued run from pool_name for owner_id with lease
lifetime ttl. Read moreSource§fn reclaim_expired_run<'a>(
&'a self,
owner_id: &'a OwnerId,
pool_name: &'a PoolName,
ttl: Duration,
) -> BoxFuture<'a, Result<Option<LeaseToken>, StoreError>>
fn reclaim_expired_run<'a>( &'a self, owner_id: &'a OwnerId, pool_name: &'a PoolName, ttl: Duration, ) -> BoxFuture<'a, Result<Option<LeaseToken>, StoreError>>
Atomically claims one expired running lease in
pool_name
(status = 'running' AND expires_at_ms <= now_ms), advances OwnerFence, updates
ownership and expiry to owner_id / ttl, and transitions all Claimed effects on
that run to Unknown. Read moreSource§fn renew_lease<'a>(
&'a self,
lease: &'a LeaseToken,
ttl: Duration,
) -> BoxFuture<'a, Result<LeaseToken, StoreError>>
fn renew_lease<'a>( &'a self, lease: &'a LeaseToken, ttl: Duration, ) -> BoxFuture<'a, Result<LeaseToken, StoreError>>
Extends the expiration timestamp of an active
lease by ttl without changing its
OwnerFence. Read moreSource§fn finish_run<'a>(
&'a self,
lease: &'a LeaseToken,
status: TerminalRunStatus,
summary_code: Option<&'a str>,
) -> BoxFuture<'a, Result<(), StoreError>>
fn finish_run<'a>( &'a self, lease: &'a LeaseToken, status: TerminalRunStatus, summary_code: Option<&'a str>, ) -> BoxFuture<'a, Result<(), StoreError>>
Marks the leased run with a terminal
TerminalRunStatus and optional summary_code,
advancing OwnerFence so subsequent calls using lease fail closed with
StoreError::StaleFence. Read moreSource§fn recover_expired_run<'a>(
&'a self,
tenant_id: &'a TenantId,
run_id: &'a RunId,
new_owner_id: &'a OwnerId,
ttl: Duration,
) -> BoxFuture<'a, Result<(LeaseToken, Vec<EffectRecord>), StoreError>>
fn recover_expired_run<'a>( &'a self, tenant_id: &'a TenantId, run_id: &'a RunId, new_owner_id: &'a OwnerId, ttl: Duration, ) -> BoxFuture<'a, Result<(LeaseToken, Vec<EffectRecord>), StoreError>>
Reclaims a specific expired running lease (
status = 'running' AND expires_at_ms <= now_ms)
for new_owner_id, returning the new LeaseToken and all Claimed effects that
transitioned atomically to Unknown. Read moreSource§fn force_recover_run<'a>(
&'a self,
tenant_id: &'a TenantId,
run_id: &'a RunId,
new_owner_id: &'a OwnerId,
ttl: Duration,
) -> BoxFuture<'a, Result<LeaseToken, StoreError>>
fn force_recover_run<'a>( &'a self, tenant_id: &'a TenantId, run_id: &'a RunId, new_owner_id: &'a OwnerId, ttl: Duration, ) -> BoxFuture<'a, Result<LeaseToken, StoreError>>
Forces operator or conformance takeover of a non-terminal (
Running or
WaitingApproval) run regardless of whether its lease has expired. Read moreSource§impl SessionStore for SqliteAgentStore
impl SessionStore for SqliteAgentStore
Source§fn create_session<'a>(
&'a self,
tenant_id: &'a TenantId,
session_id: &'a SessionId,
parent_session_id: Option<&'a SessionId>,
) -> BoxFuture<'a, Result<StepCommitResult, StoreError>>
fn create_session<'a>( &'a self, tenant_id: &'a TenantId, session_id: &'a SessionId, parent_session_id: Option<&'a SessionId>, ) -> BoxFuture<'a, Result<StepCommitResult, StoreError>>
Source§fn load_branch<'a>(
&'a self,
tenant_id: &'a TenantId,
session_id: &'a SessionId,
leaf: Option<&'a EntryId>,
) -> BoxFuture<'a, Result<LoadedBranch, StoreError>>
fn load_branch<'a>( &'a self, tenant_id: &'a TenantId, session_id: &'a SessionId, leaf: Option<&'a EntryId>, ) -> BoxFuture<'a, Result<LoadedBranch, StoreError>>
Source§impl SpendStore for SqliteAgentStore
impl SpendStore for SqliteAgentStore
Source§fn sum_spend_since<'a>(
&'a self,
tenant_id: &'a TenantId,
since_ms: i64,
billing_class: Option<BillingClass>,
) -> BoxFuture<'a, Result<MicroUsd, StoreError>>
fn sum_spend_since<'a>( &'a self, tenant_id: &'a TenantId, since_ms: i64, billing_class: Option<BillingClass>, ) -> BoxFuture<'a, Result<MicroUsd, StoreError>>
Sums all spend rows recorded for
tenant_id with recorded_at_ms >= since_ms,
optionally restricted to a single BillingClass. Read moreSource§fn sum_run_spend<'a>(
&'a self,
tenant_id: &'a TenantId,
run_id: &'a RunId,
) -> BoxFuture<'a, Result<MicroUsd, StoreError>>
fn sum_run_spend<'a>( &'a self, tenant_id: &'a TenantId, run_id: &'a RunId, ) -> BoxFuture<'a, Result<MicroUsd, StoreError>>
Sums all spend rows recorded for
(tenant_id, run_id) across all billing classes. Read moreAuto Trait Implementations§
impl Forget for SqliteAgentStore
impl Freeze for SqliteAgentStorewhere
*const ArcInner<Chan<ActorReq, Semaphore>> is !null: Freeze,
PhantomData<ArcInner<Chan<ActorReq, Semaphore>>>: Freeze,
*const ArcInner<Path> is !null: Freeze,
PhantomData<ArcInner<Path>>: Freeze,
impl Move for SqliteAgentStore
impl RefUnwindSafe for SqliteAgentStore
impl Send for SqliteAgentStore
impl Sync for SqliteAgentStore
impl Unpin for SqliteAgentStore
impl UnsafeUnpin for SqliteAgentStorewhere
*const ArcInner<Chan<ActorReq, Semaphore>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Chan<ActorReq, Semaphore>>>: UnsafeUnpin,
*const ArcInner<Path> is !null: UnsafeUnpin,
PhantomData<ArcInner<Path>>: UnsafeUnpin,
impl UnwindSafe for SqliteAgentStore
Blanket Implementations§
impl<T> AgentStore for T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more