Documentation
¶
Overview ¶
Package eventlog is the daemon's append-only event log: one JSON event per line in segment files (events.log, events.log.1, … newest first), a monotonically increasing seq that survives restarts, and an in-memory ring of the latest events that answers `since` queries without touching disk.
Retention drops whole old segments by age and by count. Nothing is fsynced per event; Close syncs the active segment.
Index ¶
- type Log
- func (l *Log) Any(pred func(*wire.Event) bool) bool
- func (l *Log) Append(ev wire.Event) (wire.Event, error)
- func (l *Log) Close() error
- func (l *Log) Seq() int64
- func (l *Log) SetRetention(maxEvents int, maxAge time.Duration) error
- func (l *Log) Since(since int64) (events []wire.Event, truncated bool)
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log is safe for concurrent use.
func Open ¶
Open loads (or creates) the log at base. It reads segments newest first until MaxEvents events are in memory, restores seq from the newest event and deletes segments beyond retention.
func (*Log) Any ¶
Any reports whether a retained event satisfies pred, scanning newest first without copying the ring.
func (*Log) Append ¶
Append assigns the next seq (and Time when zero) and writes ev. On a write error the event is still assigned and kept in memory.
func (*Log) SetRetention ¶
SetRetention changes the count and age limits (config.set). The ring shrinks or grows (growth only fills with future events).
type Options ¶
type Options struct {
// MaxEvents bounds the in-memory ring and the retained events.
MaxEvents int
// MaxAge drops events (and whole segments) older than this.
MaxAge time.Duration
// SegmentBytes rotates the active segment once it would exceed this size.
SegmentBytes int64
// SegmentAge rotates the active segment once its first event is older
// than this, so age-based retention works on quiet hosts too.
SegmentAge time.Duration
// Now is the clock (tests).
Now func() time.Time
}
Options configures a Log. Zero fields take the defaults.