eventlog

package
v0.6.76 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0, Apache-2.0, MIT Imports: 17 Imported by: 0

Documentation

Overview

Package eventlog is the daemon's offset-addressed event log (section 4.6). It lives under ~/.plural/events on the workspace volume, so it survives suspends, snapshots and daemon restarts. The gateway reads it with Daemon.SubscribeEvents(from_offset) and acknowledges what reached console with AckEvents, after which fully acknowledged segments are deleted. Transcript content isn't kept here (see package transcript).

Layout: segment files named seg-<first offset, 20 digits>.log holding length-prefixed DaemonEvent protos, plus state.json with the acknowledged offset and the offset floor.

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("event log closed")

ErrClosed is returned by operations on a closed log.

Functions

This section is empty.

Types

type Log

type Log struct {
	// contains filtered or unexported fields
}

Log is a durable append-only event log. It is safe for concurrent use.

func Open

func Open(dir string, opts ...Option) (*Log, error)

Open opens or creates the log in dir, recovering the head offset and truncating a torn trailing record.

func (*Log) Ack

func (l *Log) Ack(offset uint64) (uint64, error)

Ack records that everything up to offset reached console and deletes fully acknowledged segments. Offsets beyond the head are clamped; lower offsets than the current ack are ignored.

func (*Log) Acked

func (l *Log) Acked() uint64

Acked is the latest offset the gateway acknowledged.

func (*Log) Append

func (l *Log) Append(ev *devboxv1.DaemonEvent) (uint64, error)

Append assigns the next offset to ev, persists it and wakes subscribers. It returns the offset.

func (*Log) Close

func (l *Log) Close() error

Close syncs and closes the log, waking subscribers.

func (*Log) Head

func (l *Log) Head() uint64

Head is the latest offset written.

func (*Log) Reset

func (l *Log) Reset() error

Reset discards every record (e.g. when a snapshot is restored as a new instance) while keeping offsets monotonic, and marks everything up to the head as acknowledged.

func (*Log) Subscribe

func (l *Log) Subscribe(ctx context.Context, from uint64, fn func(*devboxv1.DaemonEvent) error) error

Subscribe calls fn for every event with offset > from, in order, then follows the log live until ctx ends or fn returns an error. Events trimmed before they could be read are skipped.

func (*Log) Sync

func (l *Log) Sync() error

Sync flushes the active segment to stable storage.

func (*Log) SyncEvery

func (l *Log) SyncEvery(ctx context.Context, d time.Duration)

SyncEvery syncs the log on an interval until ctx ends.

type Option

type Option func(*Log)

Option configures a Log.

func WithSegmentBytes

func WithSegmentBytes(n int64) Option

WithSegmentBytes sets the size at which the active segment rotates.

Jump to

Keyboard shortcuts

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