Documentation
¶
Index ¶
- Variables
- func DeleteAttachmentRows(ctx context.Context, db *sql.DB, table string, eventUUIDs []string) error
- func Open(dsn string) (*sql.DB, error)
- func OpenPooled(dsn string, maxOpen int) (*sql.DB, error)
- type AttachmentStore
- type Migration
- type Migrator
- type SQLiteStore
- func (s *SQLiteStore) Delete(ctx context.Context, uuid string) error
- func (s *SQLiteStore) DeleteAll(ctx context.Context, opts event.DeleteOptions) error
- func (s *SQLiteStore) FindAll(ctx context.Context, opts event.FindOptions) ([]event.Event, error)
- func (s *SQLiteStore) FindByUUID(ctx context.Context, uuid string) (*event.Event, error)
- func (s *SQLiteStore) OnDelete(fn func(uuids []string))
- func (s *SQLiteStore) Pin(ctx context.Context, uuid string) error
- func (s *SQLiteStore) Store(ctx context.Context, ev event.Event) error
- func (s *SQLiteStore) Unpin(ctx context.Context, uuid string) error
- func (s *SQLiteStore) UpdatePayload(ctx context.Context, uuid string, payload json.RawMessage) error
Constants ¶
This section is empty.
Variables ¶
var CoreMigrations embed.FS
Functions ¶
func DeleteAttachmentRows ¶
DeleteAttachmentRows removes the rows of an attachments table (columns event_uuid, …) that belong to the given events. Modules call it from OnEventsDeleted; the files themselves are removed by AttachmentStore.
func OpenPooled ¶
OpenPooled opens the database with a pool of maxOpen connections.
A single connection is only required for writing: in WAL mode readers block neither the writer nor each other, while one shared connection turns every heavy SELECT into a queue for ingestion — the UI and the incoming events wait for each other.
There is one correctness requirement: WAL still allows a single writer, so with maxOpen > 1 the DSN needs busy_timeout, otherwise a second write fails with SQLITE_BUSY instead of waiting. Both that and _txlock=immediate are added when absent.
Types ¶
type AttachmentStore ¶
type AttachmentStore struct {
// contains filtered or unexported fields
}
AttachmentStore provides file storage for attachments. Supports in-memory (default) and filesystem modes.
func NewAttachmentStore ¶
func NewAttachmentStore(mode, dir string) *AttachmentStore
NewAttachmentStore creates an attachment store. mode: "memory" (default) or "filesystem" dir: base directory for filesystem mode (ignored for memory)
func (*AttachmentStore) DeleteByEvent ¶
func (s *AttachmentStore) DeleteByEvent(eventUUID string)
DeleteByEvent removes all files for an event. An empty UUID or one that is not a single path element is ignored, so a bad value can never remove the base directory or a path outside it.
func (*AttachmentStore) Get ¶
func (s *AttachmentStore) Get(path string) ([]byte, error)
Get retrieves attachment content.
func (*AttachmentStore) GetReader ¶
func (s *AttachmentStore) GetReader(path string) (io.ReadCloser, error)
GetReader returns a reader for the attachment.
type Migration ¶
type Migration struct {
Name string // e.g., "2024_01_01_000000_create_events_table.sql"
Module string // e.g., "core", "profiler"
Content string
}
Migration represents a single SQL migration file.
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
Migrator collects and runs SQL migrations from all modules.
func NewMigrator ¶
func (*Migrator) AddFromFS ¶
AddFromFS registers all .sql files from an embedded filesystem. Files are expected to be named like: 2024_01_01_000000_description.sql
type SQLiteStore ¶
type SQLiteStore struct {
// contains filtered or unexported fields
}
SQLiteStore implements event.Store using SQLite.
func NewSQLiteStore ¶
func NewSQLiteStore(db *sql.DB) *SQLiteStore
func (*SQLiteStore) DeleteAll ¶
func (s *SQLiteStore) DeleteAll(ctx context.Context, opts event.DeleteOptions) error
func (*SQLiteStore) FindAll ¶
func (s *SQLiteStore) FindAll(ctx context.Context, opts event.FindOptions) ([]event.Event, error)
func (*SQLiteStore) FindByUUID ¶
func (*SQLiteStore) OnDelete ¶
func (s *SQLiteStore) OnDelete(fn func(uuids []string))
OnDelete registers fn to run after Delete or DeleteAll removed events. fn gets the UUIDs of the removed rows, so files kept outside SQLite (attachments, trace files) can be removed with them. Register hooks at startup, before the store is used.
func (*SQLiteStore) UpdatePayload ¶
func (s *SQLiteStore) UpdatePayload(ctx context.Context, uuid string, payload json.RawMessage) error