Documentation
¶
Overview ¶
Package events provides the persisted, node-local event log that powers `rune describe` (Phase 2) and any future telemetry consumer (RUNE-0XX) via the cursor view described in RUNE-126 §5.6.
The log is append-only and stored directly on the shared Badger instance (no OrderedLog / Raft coupling — events are observability, not consensus). Per-key TTL handles GC; an in-memory ring sits in front of the store as a read cache + the fold check for repeated consecutive events.
Two indexes over one logical record:
events/<ns>/<kind>/<name>/<seqBE> → JSON(Event) eventseq/<seqBE> → JSON(Event) (denormalised for cursor reads) eventcursors/<consumerID> → int64 (last delivered Seq)
Both event indexes carry the same TTL and the same payload; consumer cursors are never TTL'd.
Index ¶
- type EventLog
- type Options
- type Recorder
- func (r *Recorder) Emit(ctx context.Context, e types.Event) error
- func (r *Recorder) ListByResource(ctx context.Context, ns, kind, name string, limit int) ([]types.Event, error)
- func (r *Recorder) ListSince(ctx context.Context, cursor int64, limit int) ([]types.Event, error)
- func (r *Recorder) LoadCursor(ctx context.Context, consumerID string) (int64, error)
- func (r *Recorder) SaveCursor(ctx context.Context, consumerID string, seq int64) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventLog ¶
type EventLog interface {
Emit(ctx context.Context, e types.Event) error
ListByResource(ctx context.Context, namespace, kind, name string, limit int) ([]types.Event, error)
ListSince(ctx context.Context, cursor int64, limit int) ([]types.Event, error)
LoadCursor(ctx context.Context, consumerID string) (int64, error)
SaveCursor(ctx context.Context, consumerID string, seq int64) error
}
EventLog is the contract controllers and consumers depend on. It matches the surface in RUNE-126 §5.6 verbatim. *Recorder is the production implementation; tests may inject fakes.
type Options ¶
type Options struct {
// TTL is the Badger per-entry TTL applied to event records. Zero
// uses defaultTTL. Cursors are never TTL'd.
TTL time.Duration
// RingPerKey bounds the in-memory ring per (namespace, kind, name).
// Zero uses defaultRingPerKey.
RingPerKey int
}
Options configures a Recorder.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder is the EventLog implementation. Safe for concurrent use.
func NewRecorder ¶
NewRecorder constructs a Recorder over the given Badger handle and restores the node-global Seq counter by scanning the by-seq index. Pass BadgerStore.DB() — this package never opens its own DB.
func (*Recorder) Emit ¶
Emit appends an event to the log, folding into the most recent like-for-like event for the same (ns, kind, name) when the dedup key matches. A folded event keeps its original Seq; only Count and LastSeen change. Consumers re-deliver on Count change (idempotent via ID).
func (*Recorder) ListByResource ¶
func (r *Recorder) ListByResource(ctx context.Context, ns, kind, name string, limit int) ([]types.Event, error)
ListByResource returns up to limit most-recent events for the resource, newest first. limit <= 0 means "all in the ring/store" (capped at RingPerKey).
func (*Recorder) ListSince ¶
ListSince returns up to limit events with Seq > cursor, in ascending Seq order. This is the outbox view RUNE-0XX consumers use; see RUNE-126 §5.6.
func (*Recorder) LoadCursor ¶
LoadCursor returns the last-delivered Seq for the consumer, or 0 if the consumer is unknown.