pub struct Store { /* private fields */ }Expand description
Handle to the storage engine.
Cheap to clone (sender + Arc internally). The proxy holds one, and CLI query commands can open their own read-only connections separately.
Implementations§
Source§impl Store
impl Store
Sourcepub fn open(config: StoreConfig) -> Result<Self, StoreError>
pub fn open(config: StoreConfig) -> Result<Self, StoreError>
Open or create the database, run migrations, and spawn the writer thread.
This is called once on proxy startup. It:
- Creates the parent directory if needed.
- Opens a read-write connection and runs schema migrations.
- Spawns the background writer on a dedicated OS thread.
- Returns a
Storehandle for recording events.
§Errors
Returns an error if:
- The parent directory can’t be created (permissions).
- SQLite can’t open the file (disk full, corrupt file).
- Schema migrations fail (shouldn’t happen on fresh DBs).
Sourcepub fn record(&self, event: StoreEvent)
pub fn record(&self, event: StoreEvent)
Record an event — non-blocking, fire-and-forget.
If the channel is full (back-pressure), the event is silently dropped. This is intentional: a busy proxy must never block on storage writes. Dropped events are a signal that the writer can’t keep up — in practice this should never happen at normal MCP request rates.
Sourcepub fn db_path(&self) -> &PathBuf
pub fn db_path(&self) -> &PathBuf
Get the database path for opening read-only query connections.
Sourcepub fn shutdown(&mut self)
pub fn shutdown(&mut self)
Graceful shutdown — close the channel and wait for the writer to flush.
Call this on proxy shutdown (after stopping new requests, before exiting). Blocks the current thread until all pending events are written to SQLite.
After this returns, the database file is consistent and safe to read.