Skip to main content

SqliteStore

Struct SqliteStore 

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

Durable Troupekit store over one SQLite file in WAL mode. Cheap to clone; clones share one connection. Every call runs on tokio’s blocking pool, so it needs a tokio runtime. A caller that stops waiting does not stop the call: it runs to its commit or rollback.

Implementations§

Source§

impl SqliteStore

Source

pub async fn job(&self, run_id: RunId) -> Result<Option<JobState>, CoreError>

Returns the state of run_id’s job, as InMemQueue::job does. Input: the run. Output: None when the run was never enqueued, or CoreError::Store for a row the file should not hold.

Source§

impl SqliteStore

Source

pub async fn vectors( &self, name: &str, settings: VectorSettings, ) -> Result<SqliteVectors, CoreError>

Opens the vector index name, creating it on first use. Input: a name of 1 to 64 chars in [a-z0-9_] and its settings. Output: a handle, CoreError::DimensionMismatch when the stored index has other dims, or CoreError::Store for bad settings.

Source§

impl SqliteStore

Source

pub fn builder(path: impl AsRef<Path>) -> SqliteStoreBuilder

Starts a builder for the file at path with every setting at its default. Input: the file path. Output: the builder; nothing is opened until open.

Source

pub async fn open(path: impl AsRef<Path>) -> Result<SqliteStore, CoreError>

Opens the file at path with every setting at its default. Same as SqliteStore::builder(path).open(). Output: the store, or CoreError::Store.

Trait Implementations§

Source§

impl BlobStore for SqliteStore

Source§

fn put<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, bytes: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), CoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn get<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, CoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

impl CheckpointStore for SqliteStore

Source§

fn save<'life0, 'async_trait>( &'life0 self, cp: Checkpoint, ) -> Pin<Box<dyn Future<Output = Result<(), CoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn latest<'life0, 'async_trait>( &'life0 self, run_id: RunId, ) -> Pin<Box<dyn Future<Output = Result<Option<Checkpoint>, CoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn history<'life0, 'async_trait>( &'life0 self, run_id: RunId, ) -> Pin<Box<dyn Future<Output = Result<Vec<Checkpoint>, CoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the kept checkpoints of run_id, lowest step first. The default lists latest as zero or one checkpoint, which is exact for a store that keeps only the latest step.
Source§

fn prune<'life0, 'async_trait>( &'life0 self, run_id: RunId, keep_last: u64, ) -> Pin<Box<dyn Future<Output = Result<u64, CoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Deletes all but the keep_last highest steps of run_id and returns how many it deleted. The latest step is never deleted, so save keeps its next-step rule. keep_last == 0 returns CoreError::Store. The default deletes nothing.
Source§

impl Clone for SqliteStore

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SqliteStore

Source§

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

Formats the value using the given formatter. Read more
Source§

impl JobQueue for SqliteStore

Source§

fn enqueue<'life0, 'async_trait>( &'life0 self, run_id: RunId, due_ms: i64, ) -> Pin<Box<dyn Future<Output = Result<(), CoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn claim_due<'life0, 'async_trait>( &'life0 self, limit: usize, lease_ms: i64, ) -> Pin<Box<dyn Future<Output = Result<Vec<Lease>, CoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn complete<'life0, 'life1, 'async_trait>( &'life0 self, lease: &'life1 Lease, ) -> Pin<Box<dyn Future<Output = Result<(), CoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn fail<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, lease: &'life1 Lease, error: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), CoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source§

fn reschedule<'life0, 'life1, 'async_trait>( &'life0 self, lease: &'life1 Lease, due_ms: i64, ) -> Pin<Box<dyn Future<Output = Result<(), CoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

impl MemoryLog for SqliteStore

Source§

fn append<'life0, 'life1, 'async_trait>( &'life0 self, log: &'life1 str, expected_len: u64, entries: Vec<Message>, ) -> Pin<Box<dyn Future<Output = Result<u64, CoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn read<'life0, 'life1, 'async_trait>( &'life0 self, log: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, CoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

impl UsageLedger for SqliteStore

Source§

fn period_total<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<u64, CoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn record<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, usage: Usage, ) -> Pin<Box<dyn Future<Output = Result<(), CoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Auto Trait Implementations§

§

impl !RefUnwindSafe for SqliteStore

§

impl !UnwindSafe for SqliteStore

§

impl Forget for SqliteStore

§

impl Freeze for SqliteStore
where *const ArcInner<Inner> is !null: Freeze, PhantomData<ArcInner<Inner>>: Freeze,

§

impl Move for SqliteStore

§

impl Send for SqliteStore
where Arc<Inner>: Send,

§

impl Sync for SqliteStore
where Arc<Inner>: Sync,

§

impl Unpin for SqliteStore
where Arc<Inner>: Unpin,

§

impl UnsafeUnpin for SqliteStore
where *const ArcInner<Inner> is !null: UnsafeUnpin, PhantomData<ArcInner<Inner>>: UnsafeUnpin,

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

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.