Documentation
¶
Overview ¶
Package logstore defines the per-node log storage contract (spec §3.10). The segmented, zstd-compressed implementation is task T-50; the fake lives in testutil.
Index ¶
- type Entry
- type Options
- type Query
- type Segmented
- func (s *Segmented) Append(stream StreamID, entries []Entry) error
- func (s *Segmented) Close() error
- func (s *Segmented) DeleteStream(stream StreamID) error
- func (s *Segmented) Follow(ctx context.Context, q Query) (<-chan Entry, error)
- func (s *Segmented) Query(ctx context.Context, q Query) ([]Entry, error)
- type Store
- type StreamID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
Root string // <data-dir>/logs
Clock clock.Clock
MaxSegmentBytes int64 // 0 = default 8MB
MaxSegmentAge time.Duration // 0 = default 1h
RetentionBytes int64 // per-stream compressed cap; 0 = unlimited
RetentionAge time.Duration // 0 = unlimited
}
Options configures a Segmented store.
type Query ¶
type Query struct {
Streams []StreamID
Since time.Time
Until time.Time // zero = now
Limit int // 0 = default 1000
}
Query selects entries from one or more streams.
type Segmented ¶
type Segmented struct {
// contains filtered or unexported fields
}
Segmented is a per-node, on-disk log store: an uncompressed active segment per stream, rotated (at size/age) into zstd-compressed segments with sparse time indexes. Reads binary-search segments by time; Follow tails live appends through an in-memory hub.
func (*Segmented) Append ¶
Append writes entries to a stream, rotating when the active segment is full, and notifies live followers.
func (*Segmented) DeleteStream ¶
DeleteStream removes a stream's directory and forgets it.
type Store ¶
type Store interface {
// Append adds entries to a stream (creating it on first write). Entries
// must be in non-decreasing time order per call.
Append(stream StreamID, entries []Entry) error
// Query returns matching entries in time order.
Query(ctx context.Context, q Query) ([]Entry, error)
// Follow returns history matching q, then keeps streaming live entries
// until ctx is canceled. The channel is closed on ctx cancellation.
Follow(ctx context.Context, q Query) (<-chan Entry, error)
// DeleteStream drops a stream's segments (retention, app deletion).
DeleteStream(stream StreamID) error
Close() error
}
Store is the per-node log store. Append is called by the agent's tailers; Query/Follow serve the AgentLocalService fan-out.