Documentation
¶
Overview ¶
Package logstore is the dedicated, bounded, append-only persistence layer for ingested node log lines. It owns its own bbolt database (logs.db) and is deliberately NOT part of the whole-file JSON state store: log volume must never trigger a full state rewrite. Storage is append-O(record), time-ordered by a server-assigned per-source sequence, and bounded by a per-source byte cap with oldest-first eviction so disk can never grow unbounded.
Index ¶
- Constants
- func EnvMaxSourceBytes(raw string) int64
- type Filter
- type Meta
- type Result
- type Store
- func (s *Store) Append(sourceID string, lines []model.LogLine, rotID string, lastOff uint64, ...) (uint64, error)
- func (s *Store) Close() error
- func (s *Store) FileSize() int64
- func (s *Store) Path() string
- func (s *Store) PurgeSource(sourceID string) error
- func (s *Store) Query(f Filter) (Result, error)
- func (s *Store) SourceBytesCap() uint64
- func (s *Store) Stats(sourceID string) (Meta, time.Time, time.Time, bool)
Constants ¶
const ( // DefaultMaxSourceBytes caps stored (post-encode) bytes per source; the // oldest chunks are evicted on append once exceeded. DefaultMaxSourceBytes = 64 << 20 // 64 MiB // DefaultQueryLimit / MaxQueryLimit bound a single query's line count. DefaultQueryLimit = 200 MaxQueryLimit = 1000 )
Variables ¶
This section is empty.
Functions ¶
func EnvMaxSourceBytes ¶
EnvMaxSourceBytes parses an optional per-source byte cap override.
Types ¶
type Filter ¶
type Filter struct {
SourceID string
Since time.Time
Until time.Time
Contains string // case-insensitive substring; empty matches all
Limit int // clamped to [1, MaxQueryLimit]; 0 => DefaultQueryLimit
BeforeSeq uint64 // cursor: only chunks with Seq < BeforeSeq (0 => from newest)
}
Filter is a per-source query. Cross-source merge is the server's job.
type Meta ¶
type Meta struct {
FirstSeq uint64 `json:"first_seq"`
LastSeq uint64 `json:"last_seq"`
Bytes uint64 `json:"bytes"`
Lines uint64 `json:"lines"`
RotID string `json:"rot_id"`
LastOff uint64 `json:"last_off"`
LastIngestAt time.Time `json:"last_ingest_at"`
}
Meta is the per-source bookkeeping record (also the stats projection).
type Result ¶
type Result struct {
Lines []model.LogLine
NextBeforeSeq uint64 // pass back as Filter.BeforeSeq to page older; 0 => no more
Truncated bool // a stored chunk failed to decode and was skipped
}
Result is a newest-first page of lines.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a bbolt-backed bounded log store.
func Open ¶
Open opens (creating if needed) the log store at path. A nil or disabled cipher stores chunks in plaintext; an enabled cipher seals each chunk as a unit. maxSourceBytes<=0 uses DefaultMaxSourceBytes.
func (*Store) Append ¶
func (s *Store) Append(sourceID string, lines []model.LogLine, rotID string, lastOff uint64, at time.Time) (uint64, error)
Append packs lines into one chunk under the next sequence for sourceID, updates the source meta (rotID/lastOff/lastIngestAt from the batch context), and evicts oldest chunks until the per-source byte cap is honored. It returns the assigned chunk sequence. lines must already be truncated/validated by the caller; their Seq field is overwritten with the assigned sequence.
func (*Store) PurgeSource ¶
PurgeSource drops a source's data bucket and meta (used on source delete).
func (*Store) SourceBytesCap ¶
SourceBytesCap reports the configured per-source byte cap (for diagnostics).