Function: registerDrizzleSessionStorage()
Makaio Framework / services-core / registerDrizzleSessionStorage
Function: registerDrizzleSessionStorage()
Section titled “Function: registerDrizzleSessionStorage()”registerDrizzleSessionStorage(
bus,db,_ctx): () =>void
Defined in: ../../../packages/services/core/src/session/storage/drizzle-handler.ts:575
Register Drizzle-based session storage handlers.
Persists sessions to SQLite/libSQL via Drizzle ORM. Provides durable storage suitable for production deployments.
CONCURRENCY INVARIANT: All handlers must use single-statement operations only. Storage handlers share a single DB connection. Fire-and-forget bus events (e.g., agent.added) race with sequential RPC handlers (e.g., turn.create). db.transaction() holds write locks across await boundaries, causing SQLITE_BUSY deadlocks on the same connection. Single statements serialize automatically via SQLite’s busy_timeout + WAL mode.
Parameters
Section titled “Parameters”The bus instance to register handlers on
MakaioDatabase
The Drizzle database instance (any libSQL database)
Extension context (unused; reserved for future use)
Returns
Section titled “Returns”Cleanup function to unsubscribe all handlers
() => void
Example
Section titled “Example”import { registerDrizzleSessionStorage } from '@makaio/services-core/session';import { drizzle } from 'drizzle-orm/libsql';import { createClient } from '@libsql/client';
const client = createClient({ url: 'file:./makaio.db' });const db = drizzle(client);const cleanup = registerDrizzleSessionStorage(bus, db, ctx);
// Later, when shutting down:cleanup();