Skip to content

Function: registerDrizzleSessionStorage()

Makaio Framework


Makaio Framework / services-core / 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.

IMakaioBus

The bus instance to register handlers on

MakaioDatabase

The Drizzle database instance (any libSQL database)

ExtensionContext

Extension context (unused; reserved for future use)

Cleanup function to unsubscribe all handlers

() => void

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();