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 ¶
- Variables
- type Log
- func (l *Log) Ack(offset uint64) (uint64, error)
- func (l *Log) Acked() uint64
- func (l *Log) Append(ev *devboxv1.DaemonEvent) (uint64, error)
- func (l *Log) Close() error
- func (l *Log) Head() uint64
- func (l *Log) Reset() error
- func (l *Log) Subscribe(ctx context.Context, from uint64, fn func(*devboxv1.DaemonEvent) error) error
- func (l *Log) Sync() error
- func (l *Log) SyncEvery(ctx context.Context, d time.Duration)
- type Option
Constants ¶
This section is empty.
Variables ¶
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 ¶
Open opens or creates the log in dir, recovering the head offset and truncating a torn trailing record.
func (*Log) Ack ¶
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) 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) Reset ¶
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.