statushistory

package
v0.0.0-...-0d10c26 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DataMarshalError is returned when marshaling data fails.
	DataMarshalError = errors.ConstError("data-marshal-error")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Namespace

type Namespace struct {
	Name string
	ID   string
}

Namespace represents a namespace of the status we're recording.

func (Namespace) String

func (n Namespace) String() string

func (Namespace) WithID

func (n Namespace) WithID(id string) Namespace

WithID returns a new namespace with the given ID.

type Record

type Record struct {
	Name    string
	ID      string
	Message string
	Status  string
	Time    string
	Data    map[string]any
}

Record represents a single record of status information.

type Recorder

type Recorder interface {
	// Record records the given status information.
	Record(context.Context, Record) error
}

Recorder is an interface for recording status information.

func NewLogRecorder

func NewLogRecorder(log logger.Logger) Recorder

NewLogRecorder returns a new logRecorder that logs to the given logger.

type StatusHistory

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

StatusHistory records status information into a generalized way.

func NewStatusHistory

func NewStatusHistory(recorder Recorder) *StatusHistory

NewStatusHistory creates a new StatusHistory.

func (*StatusHistory) RecordStatus

func (s *StatusHistory) RecordStatus(ctx context.Context, ns Namespace, status status.StatusInfo) error

RecordStatus records the given status information. If the status data cannot be marshalled, it will not be recorded, instead the error will be logged under the data_error key.

Jump to

Keyboard shortcuts

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