file

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package file is a durable store.Store: an append-only JSONL event log that replays into memory on open. Pure Go, zero dependencies — the single static binary stays single and static, and events survive restarts. The append log is the source of truth; queries are served from the in-memory index (same speed as the memory store). This is the smol, always-correct default for a single box; the columnar segment tier (internal/store/segment) sits behind the same interface for scale.

Index

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
}

func Open

func Open(path string) (*Store, error)

Open replays the log at path (creating it and any parent dirs if absent) and returns a store ready to append. Corrupt trailing lines are skipped, not fatal.

func (*Store) Clear

func (s *Store) Clear() error

Clear truncates the event log and resets the in-memory index.

func (*Store) Close

func (s *Store) Close() error

Close flushes and closes the append handle.

func (*Store) Count

func (s *Store) Count() int

Count is the number of events held (handy for "is this store empty").

func (*Store) DeleteUser added in v0.3.0

func (s *Store) DeleteUser(distinctID string) (int, error)

DeleteUser erases every event for one distinct_id (GDPR erasure), rewriting the log via the same atomic temp-file+rename path compaction uses.

func (*Store) Ingest

func (s *Store) Ingest(events ...event.Event) error

func (*Store) Names

func (s *Store) Names() ([]string, error)

func (*Store) Prune

func (s *Store) Prune(before time.Time) (int, error)

Prune drops events older than the cutoff and compacts the log. Runs under the write lock; O(n) but only on the retention schedule.

func (*Store) Range

func (s *Store) Range(from, to time.Time) ([]event.Event, error)

func (*Store) Scan added in v0.2.0

func (s *Store) Scan(from, to time.Time, fn func(event.Event) error) error

func (*Store) SetMaxEvents added in v0.2.0

func (s *Store) SetMaxEvents(n int) error

SetMaxEvents bounds how many of the most-recent events stay resident (0 = unlimited). This is the guardrail that keeps a small instance alive under a flood of ingest instead of OOM-crashing it; it trims immediately if already over. Pair it with retention (RetainDays) to also bound the on-disk log.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL