Documentation
¶
Overview ¶
Package sqlite provides a SQLite-backed Storage adapter for Chronos.
Index ¶
- type Option
- type Store
- func (s *Store) AppendAuditLog(ctx context.Context, log *storage.AuditLog) error
- func (s *Store) AppendEvent(ctx context.Context, e *storage.Event) error
- func (s *Store) AppendEvents(ctx context.Context, events []*storage.Event) error
- func (s *Store) Close() error
- func (s *Store) CreateSession(ctx context.Context, sess *storage.Session) error
- func (s *Store) DeleteMemory(ctx context.Context, id string) error
- func (s *Store) GetCheckpoint(ctx context.Context, id string) (*storage.Checkpoint, error)
- func (s *Store) GetLatestCheckpoint(ctx context.Context, sessionID string) (*storage.Checkpoint, error)
- func (s *Store) GetMemory(ctx context.Context, agentID, key string) (*storage.MemoryRecord, error)
- func (s *Store) GetSession(ctx context.Context, id string) (*storage.Session, error)
- func (s *Store) GetTrace(ctx context.Context, id string) (*storage.Trace, error)
- func (s *Store) InsertTrace(ctx context.Context, t *storage.Trace) error
- func (s *Store) InsertTraces(ctx context.Context, traces []*storage.Trace) error
- func (s *Store) ListAuditLogs(ctx context.Context, sessionID string, limit, offset int) ([]*storage.AuditLog, error)
- func (s *Store) ListCheckpoints(ctx context.Context, sessionID string) ([]*storage.Checkpoint, error)
- func (s *Store) ListCheckpointsPaged(ctx context.Context, sessionID string, limit int, cursor string) (*storage.CheckpointPage, error)
- func (s *Store) ListEvents(ctx context.Context, sessionID string, afterSeq int64) ([]*storage.Event, error)
- func (s *Store) ListEventsPaged(ctx context.Context, sessionID string, afterSeq int64, limit int, ...) (*storage.EventPage, error)
- func (s *Store) ListMemory(ctx context.Context, agentID, kind string) ([]*storage.MemoryRecord, error)
- func (s *Store) ListSessions(ctx context.Context, agentID string, limit, offset int) ([]*storage.Session, error)
- func (s *Store) ListTraces(ctx context.Context, sessionID string) ([]*storage.Trace, error)
- func (s *Store) ListTracesPaged(ctx context.Context, sessionID string, limit int, cursor string) (*storage.TracePage, error)
- func (s *Store) Migrate(ctx context.Context) error
- func (s *Store) PutMemory(ctx context.Context, m *storage.MemoryRecord) error
- func (s *Store) SaveCheckpoint(ctx context.Context, cp *storage.Checkpoint) error
- func (s *Store) SaveCheckpointAndEvent(ctx context.Context, cp *storage.Checkpoint, evt *storage.Event) error
- func (s *Store) TrimAuditLogs(ctx context.Context, olderThan time.Time) (int64, error)
- func (s *Store) TrimCheckpoints(ctx context.Context, sessionID string, keep int) (int64, error)
- func (s *Store) TrimEvents(ctx context.Context, olderThan time.Time) (int64, error)
- func (s *Store) TrimTraces(ctx context.Context, olderThan time.Time) (int64, error)
- func (s *Store) UpdateSession(ctx context.Context, sess *storage.Session) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶ added in v0.4.0
type Option func(*poolConfig)
Option configures a Store's connection pool. SQLite defaults to a single open connection because it is single-writer; overrides are honored but rarely advisable for on-disk databases.
func WithConnMaxLifetime ¶ added in v0.4.0
WithConnMaxLifetime sets the maximum lifetime of a connection.
func WithMaxIdleConns ¶ added in v0.4.0
WithMaxIdleConns sets the maximum number of idle connections.
func WithMaxOpenConns ¶ added in v0.4.0
WithMaxOpenConns sets the maximum number of open connections.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements storage.Storage using SQLite.
func (*Store) AppendAuditLog ¶
func (*Store) AppendEvent ¶
AppendEvent appends a ledger event. It is idempotent: re-appending an event with an existing id is a no-op, so replay/resume cannot error on the primary key or duplicate the ledger.
func (*Store) AppendEvents ¶ added in v0.4.0
AppendEvents appends many events within one transaction. It is idempotent on event id (INSERT OR IGNORE). The batch is split into chunks so the per-statement bind-parameter count stays under sqliteMaxBindParams; all chunks run in the same transaction, so the whole batch still commits (or rolls back) atomically.
func (*Store) CreateSession ¶
func (*Store) GetCheckpoint ¶
func (*Store) GetLatestCheckpoint ¶
func (*Store) GetSession ¶
func (*Store) InsertTrace ¶
func (*Store) InsertTraces ¶ added in v0.4.0
InsertTraces inserts many trace spans within one transaction. As with AppendEvents the batch is chunked to respect sqliteMaxBindParams while keeping the whole insert atomic.
func (*Store) ListAuditLogs ¶
func (*Store) ListCheckpoints ¶
func (*Store) ListCheckpointsPaged ¶ added in v0.4.0
func (s *Store) ListCheckpointsPaged(ctx context.Context, sessionID string, limit int, cursor string) (*storage.CheckpointPage, error)
ListCheckpointsPaged returns a cursor-paginated page of checkpoints ordered by seq_num.
func (*Store) ListEvents ¶
func (*Store) ListEventsPaged ¶ added in v0.4.0
func (s *Store) ListEventsPaged(ctx context.Context, sessionID string, afterSeq int64, limit int, cursor string) (*storage.EventPage, error)
ListEventsPaged returns a cursor-paginated page of events after afterSeq, ordered by seq_num. It fetches limit+1 rows to detect whether a further page exists, so the final page never carries a dangling cursor.
func (*Store) ListMemory ¶
func (*Store) ListSessions ¶
func (*Store) ListTraces ¶
func (*Store) ListTracesPaged ¶ added in v0.4.0
func (s *Store) ListTracesPaged(ctx context.Context, sessionID string, limit int, cursor string) (*storage.TracePage, error)
ListTracesPaged returns a cursor-paginated page of traces. It keysets on the stable primary key id (rather than the wall-clock started_at, whose text storage makes cross-timezone comparison unreliable), which gives a deterministic order across SQLite and Postgres.
func (*Store) Migrate ¶
Migrate creates all required tables and indexes via the versioned migration framework. Migration v2 adds tenant scoping.
func (*Store) SaveCheckpoint ¶
SaveCheckpoint persists a checkpoint. It is idempotent: saving a checkpoint with an existing id overwrites it, so resuming/replaying a run cannot error on the primary key.
func (*Store) SaveCheckpointAndEvent ¶ added in v0.4.0
func (s *Store) SaveCheckpointAndEvent(ctx context.Context, cp *storage.Checkpoint, evt *storage.Event) error
SaveCheckpointAndEvent persists a checkpoint and its ledger event atomically in a single transaction, satisfying graph.CheckpointCommitter. A crash cannot leave the checkpoint and event ledger out of sync.
func (*Store) TrimAuditLogs ¶ added in v0.4.0
TrimAuditLogs deletes audit logs created strictly before olderThan.
func (*Store) TrimCheckpoints ¶ added in v0.4.0
TrimCheckpoints keeps only the most recent keep checkpoints (by seq_num) for the session and deletes the rest.
func (*Store) TrimEvents ¶ added in v0.4.0
TrimEvents deletes events created strictly before olderThan.
func (*Store) TrimTraces ¶ added in v0.4.0
TrimTraces deletes traces started strictly before olderThan.