Documentation
¶
Overview ¶
Package mongo provides a MongoDB-backed Storage adapter for Chronos.
It is built on the official MongoDB Go driver (go.mongodb.org/mongo-driver). The previous implementation talked to the MongoDB Atlas Data API over net/http — a REST service that MongoDB deprecated and shut down on 2024-09-30 — and mislabelled it as "the MongoDB wire protocol". That approach is dead; this rewrite speaks the real wire protocol through the maintained driver, which handles connection pooling, retries, auth and BSON.
Document naming ¶
Chronos entities carry json tags (id, agent_id, session_id, ...). To keep field names identical across every storage backend, documents are stored as the JSON projection of each entity (entity -> JSON -> map -> BSON) and decoded back the same way. Filters therefore use json-tag names (e.g. "agent_id").
Index ¶
- 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) 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) 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) ListEvents(ctx context.Context, sessionID string, afterSeq int64) ([]*storage.Event, 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) 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) 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 Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements storage.Storage using MongoDB.
func New ¶
New connects to MongoDB at uri (e.g. "mongodb://localhost:27017") and selects the given database. Connectivity is verified with a ping.
func NewWithClient ¶ added in v0.6.0
NewWithClient wraps an existing mongo.Client (useful for tests / custom opts).
func (*Store) AppendAuditLog ¶
func (*Store) AppendEvent ¶
func (*Store) CreateSession ¶
func (*Store) GetCheckpoint ¶
func (*Store) GetLatestCheckpoint ¶
func (*Store) GetSession ¶
func (*Store) InsertTrace ¶
func (*Store) ListAuditLogs ¶
func (*Store) ListCheckpoints ¶
func (*Store) ListEvents ¶
func (*Store) ListMemory ¶
func (*Store) ListSessions ¶
func (*Store) ListTraces ¶
func (*Store) Migrate ¶
Migrate ensures indexes used by list/get queries exist. Collections are created lazily by MongoDB on first write.