logstore

package
v0.1.0-alpha.8 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Time   time.Time
	Stderr bool
	Line   string
}

Entry is one log line with its origin metadata.

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 New

func New(opts Options) (*Segmented, error)

New opens (creating) the log root and prepares the store.

func (*Segmented) Append

func (s *Segmented) Append(stream StreamID, entries []Entry) error

Append writes entries to a stream, rotating when the active segment is full, and notifies live followers.

func (*Segmented) Close

func (s *Segmented) Close() error

Close flushes and closes all active streams.

func (*Segmented) DeleteStream

func (s *Segmented) DeleteStream(stream StreamID) error

DeleteStream removes a stream's directory and forgets it.

func (*Segmented) Follow

func (s *Segmented) Follow(ctx context.Context, q Query) (<-chan Entry, error)

Follow returns history then tails live appends until ctx is canceled.

func (*Segmented) Query

func (s *Segmented) Query(ctx context.Context, q Query) ([]Entry, error)

Query returns matching entries in time order, capped to the most recent Limit.

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.

type StreamID

type StreamID string

StreamID identifies one log stream. For runtime logs use the assignment id prefixed "instance/"; for build logs "build/<build-id>"; for job runs "job/<job-id>".

Jump to

Keyboard shortcuts

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