events

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Emitter

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

Emitter sends events to a postDash service. If URL is empty, all operations are no-ops (zero overhead).

func New

func New(url, source string) *Emitter

New creates an Emitter. If url is empty, returns a no-op emitter.

func (*Emitter) Emit

func (e *Emitter) Emit(action, agentID string, data map[string]any)

Emit sends an event to the relay. Fire-and-forget — never blocks, never errors. If agentID is empty, the emitter's default agent ID is used.

func (*Emitter) EmitFull

func (e *Emitter) EmitFull(evt Event)

EmitFull sends a fully specified event to the relay. Source, TS, and AgentID (when empty) are filled automatically.

func (*Emitter) Flush

func (e *Emitter) Flush()

Flush waits for all pending events to be sent.

func (*Emitter) SetAgentID

func (e *Emitter) SetAgentID(id string)

SetAgentID sets the default agent ID used when callers pass an empty string.

type Event

type Event struct {
	Source     string         `json:"source"`
	Channel    string         `json:"channel,omitempty"`
	Action     string         `json:"action"`
	Level      string         `json:"level,omitempty"`
	AgentID    string         `json:"agent_id,omitempty"`
	DurationMS int64          `json:"duration_ms"`
	Data       map[string]any `json:"data,omitempty"`
	TS         time.Time      `json:"ts"`
}

Event is the structured payload sent to postDash.

type EventEmitter

type EventEmitter interface {
	EmitFull(evt Event)
	Flush()
	SetAgentID(id string)
}

EventEmitter sends structured events to an observability backend. The default implementation posts to a postDash HTTP endpoint. A no-op emitter is used when no URL is configured. Alternative implementations could log to files, send to different backends, etc.

Jump to

Keyboard shortcuts

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