eventlog

package
v0.7.196 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Ts          time.Time `json:"ts"`
	SidecarID   string    `json:"sidecar_id,omitempty"`
	SidecarName string    `json:"sidecar_name,omitempty"`
	Branch      string    `json:"branch,omitempty"`
	Op          Op        `json:"op"`
	Level       string    `json:"level"` // "step", "info", "warn", "done", "error"
	Msg         string    `json:"msg"`

	// Final marks the one event that closes an operation, with Passed and Total
	// carrying its tally. A reader tells a finished operation from one still in
	// flight by this, never by reading Msg.
	Final  bool `json:"final,omitempty"`
	Passed int  `json:"passed,omitempty"`
	Total  int  `json:"total,omitempty"`

	// CommandID is the sandbox-provisioner ID of the remote exec that produced
	// this event, set on pass/fail events for commands that ran on the sidecar.
	// Use GET /api/v3/sidecar/commands/{id}/output to replay the run's output.
	CommandID string `json:"command_id,omitempty"`
}

Event is a single status event written to the log.

func (Event) Outcome added in v0.7.169

func (e Event) Outcome() (passed, total int, ok bool)

Outcome reports whether e is the event that closes an operation, and the tally to show for it.

type Log

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

Log appends events to a JSONL file in a project data directory.

func Open

func Open(dataDir string) (*Log, error)

Open opens (or creates) the event log in dataDir, trimming if too large.

func (*Log) Append

func (l *Log) Append(e Event) error

Append writes a single event to the log.

func (*Log) Recent

func (l *Log) Recent(n int) ([]Event, error)

Recent returns up to n most recent events from the log.

func (*Log) Recorder added in v0.7.169

func (l *Log) Recorder(inner iostream.StatusFunc, op Op, sidecarID, sidecarName, branch string) *Recorder

Recorder returns a Recorder that reports through inner and appends each call to the log, tagged with op, sidecarID, sidecarName, and branch.

func (*Log) TailFrom

func (l *Log) TailFrom(offset int64) ([]Event, int64, error)

TailFrom returns events appended after offset, and the updated offset.

type Op

type Op string

Op identifies the kind of operation that generated an event.

const (
	OpSync     Op = "sync"
	OpValidate Op = "validate"
	OpExec     Op = "exec"
	OpSetup    Op = "setup"
	OpHook     Op = "hook"
	OpReview   Op = "review"
)

Op values for each sidecar operation type.

type Recorder added in v0.7.169

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

Recorder reports status through inner and records it in the log, tagging every event with the operation it belongs to. Status records an ordinary event; Final records the one that closes the operation.

func Record added in v0.7.169

func Record(dataDir string, fn iostream.StatusFunc, op Op, sidecarID, sidecarName, branch string) *Recorder

Record returns a Recorder writing to the log in dataDir. Errors opening the log are silently ignored (best-effort; never blocks) and the Recorder then only reports through fn.

func (*Recorder) Final added in v0.7.169

func (r *Recorder) Final(level iostream.Level, msg string, passed, total int)

Final reports the event that closes the operation, tallying the commands that passed out of those attempted. Both are zero when the operation failed before running anything.

func (*Recorder) For added in v0.7.196

func (r *Recorder) For(sidecarID, sidecarName string) *Recorder

For returns a recorder sharing this one's log, branch, op and reporter, tagged with a different sidecar. A pooled run needs one per member: readers match an event to a sidecar row on SidecarID alone, so a run recorded under a single representative ID puts every command on one row and leaves the rest of the pool blank.

The sibling keeps its own pending command ID, so SetCommandID has to be called on the recorder whose events the ID belongs to.

func (*Recorder) PerCommand added in v0.7.196

func (r *Recorder) PerCommand() iostream.StatusFunc

PerCommand returns a reporter that closes a run on each pass or failure, tallying it 1/1 or 0/1. A pool member runs one command at a time, so its events are a sequence of single-command runs rather than one long one, and each has to close for a reader to collapse it.

The closing event is the one command's own, so unlike a run-wide Final it carries the command ID set by SetCommandID.

func (*Recorder) SetCommandID added in v0.7.173

func (r *Recorder) SetCommandID(id string)

SetCommandID records the sandbox-provisioner command ID of the exec that just finished. The next pass/fail event for that command will carry this ID. Pass "" when an exec failed without reporting an ID so a stale one from a prior exec is not attributed to it.

func (*Recorder) Status added in v0.7.169

func (r *Recorder) Status(level iostream.Level, msg string)

Status reports an ordinary event, one that leaves the operation open.

Jump to

Keyboard shortcuts

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