jobevent

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package jobevent lets a sync tool (internal/dns, internal/icinga, internal/librenms, internal/netbox, internal/lime) report structured info/warning/error progress instead of ad hoc fmt.Println/slog calls. Deliberately has zero dependency on internal/worker (which is what consumes these events on the primary side, over the hub transport's "event" envelope) so neither package needs to import the other.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsoleReporter

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

ConsoleReporter writes human-readable text - the default when a CLI is run interactively (no --job), preserving roughly today's plain-print behavior for Info, with a visible prefix for Warning/Error.

func NewConsoleReporter

func NewConsoleReporter(w io.Writer) *ConsoleReporter

func (*ConsoleReporter) Emit

func (r *ConsoleReporter) Emit(level Level, format string, args ...any)

func (*ConsoleReporter) EmitErr

func (r *ConsoleReporter) EmitErr(err error)

type Level

type Level string
const (
	Info    Level = "info"
	Warning Level = "warning"
	Error   Level = "error"
)

type Reporter

type Reporter interface {
	Emit(level Level, format string, args ...any)
	// EmitErr emits err at Error level. A nil err is a no-op. Callers should
	// prefer this over Emit(Error, err.Error()), which mis-renders any '%'
	// in the error message since err.Error() is passed as a format string.
	EmitErr(err error)
}

type SlogReporter

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

SlogReporter emits via log/slog - for callers already running in-process (not as a predefined-command subprocess), e.g. web.ApiNetboxWebhook calling internal/netbox.FactumSyncNetbox directly, which has no meaningful "stdout" to write JSON lines to. Optional kv pairs (slog attrs, typically "source", "netbox") are attached to every line so the web GUI's log window can label the originating subsystem.

func NewSlogReporter

func NewSlogReporter(kv ...any) SlogReporter

func (SlogReporter) Emit

func (r SlogReporter) Emit(level Level, format string, args ...any)

func (SlogReporter) EmitErr

func (r SlogReporter) EmitErr(err error)

type StdoutReporter

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

StdoutReporter writes one JSON object per line - {"level":..., "message":...} - decoded by the agent (internal/worker/hub_agent.go's streamOutput) and relayed as a structured event instead of a plain log line. Used when a CLI is invoked with --job.

func NewStdoutReporter

func NewStdoutReporter(w io.Writer) *StdoutReporter

func (*StdoutReporter) Emit

func (r *StdoutReporter) Emit(level Level, format string, args ...any)

func (*StdoutReporter) EmitErr

func (r *StdoutReporter) EmitErr(err error)

Jump to

Keyboard shortcuts

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