event

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(tx *sql.Tx, e *Event) error

Append inserts an event into the event log within an existing transaction.

func NewULID

func NewULID() string

NewULID generates a monotonic ULID: 10 chars of millisecond timestamp + 16 chars of randomness, Crockford base32 encoded. Within the same millisecond, the random portion is incremented to guarantee lexicographic ordering.

Types

type Action

type Action string

Action represents the kind of mutation applied to a Trace.

const (
	ActionCreate    Action = "create"
	ActionUpdate    Action = "update"
	ActionArchive   Action = "archive"
	ActionUnarchive Action = "unarchive"
	ActionTrash     Action = "trash"
	ActionRecover   Action = "recover"
	ActionPurge     Action = "purge"
)

type Event

type Event struct {
	ID        string            `json:"id"` // ULID
	Action    Action            `json:"action"`
	TraceID   string            `json:"trace_id"`
	CortexID  string            `json:"cortex_id"`        // stable ULID identity (federation key)
	Origin    string            `json:"origin"`           // display name at write time
	Timestamp string            `json:"timestamp"`        // RFC3339 UTC
	Data      json.RawMessage   `json:"data,omitempty"`   // action-specific payload
	VClock    map[string]uint64 `json:"vclock,omitempty"` // vector clock keyed on cortex IDs
}

Event is an immutable record of a mutation to a Trace.

CortexID is the stable ULID identity of the cortex that produced the event. Origin is the human-readable display name at the time of writing — it can drift if the cortex is renamed and is never trusted for identity decisions on replay. Federation, vector clocks, and divergence detection all key on CortexID; Origin is purely for audit-trail rendering.

func ForTrace

func ForTrace(db *sql.DB, traceID string) ([]Event, error)

ForTrace returns all events for a given trace ID, ordered chronologically.

func Since

func Since(db *sql.DB, afterID string, limit int) ([]Event, error)

Since returns events with ID > afterID, ordered chronologically, up to limit. If afterID is "", returns from the beginning.

Jump to

Keyboard shortcuts

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