history

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncRecorder added in v0.22.0

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

AsyncRecorder records history events asynchronously.

func NewAsyncRecorder added in v0.22.0

func NewAsyncRecorder(recorder Recorder, logger *slog.Logger, buffer int) *AsyncRecorder

NewAsyncRecorder wraps a Recorder with a buffered async queue.

func (*AsyncRecorder) Add added in v0.22.0

func (a *AsyncRecorder) Add(e Event)

Add enqueues an event without blocking.

func (*AsyncRecorder) List added in v0.22.0

func (a *AsyncRecorder) List() []Event

List returns a snapshot of recorded events.

func (*AsyncRecorder) ListByID added in v0.22.0

func (a *AsyncRecorder) ListByID(heartbeatID string) []Event

ListByID returns recorded events filtered by heartbeat id.

func (*AsyncRecorder) Start added in v0.22.0

func (a *AsyncRecorder) Start(ctx context.Context)

Start begins draining the async queue until ctx is canceled.

func (*AsyncRecorder) Subscribe added in v0.22.0

func (a *AsyncRecorder) Subscribe(buffer int) (<-chan Event, func())

Subscribe registers a buffered event stream.

type Event

type Event struct {
	Time        time.Time      `json:"timestamp"`             // Event timestamp.
	Type        string         `json:"type"`                  // Event type identifier.
	HeartbeatID string         `json:"heartbeatId,omitempty"` // Heartbeat id.
	Receiver    string         `json:"receiver,omitempty"`    // Receiver name.
	TargetType  string         `json:"targetType,omitempty"`  // Delivery target type.
	Status      string         `json:"status,omitempty"`      // Status value.
	Message     string         `json:"message,omitempty"`     // Human-readable message.
	Fields      map[string]any `json:"fields,omitempty"`      // Optional fields.
}

Event represents a recorded history item.

type EventType

type EventType int

EventType represents the history event type.

const (
	EventHeartbeatReceived EventType = iota
	EventHeartbeatTransition
	EventHTTPAccess
	EventNotificationDelivered
	EventNotificationFailed
)

func (EventType) String

func (e EventType) String() string

String returns the history event identifier.

type Recorder added in v0.22.0

type Recorder interface {
	Add(Event)
	List() []Event
	ListByID(string) []Event
}

Recorder records history events.

type Store

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

Store keeps a fixed-size history buffer.

func NewStore added in v0.22.0

func NewStore(size int) *Store

NewStore constructs a Store with a fixed size.

func (*Store) Add added in v0.22.0

func (s *Store) Add(e Event)

Add records a new event.

func (*Store) List added in v0.15.1

func (s *Store) List() []Event

List returns a snapshot of events in chronological order.

func (*Store) ListByID added in v0.15.1

func (s *Store) ListByID(heartbeatID string) []Event

ListByID returns a snapshot of events in chronological order filtered by heartbeat id.

type Streamer added in v0.22.0

type Streamer interface {
	Subscribe(buffer int) (<-chan Event, func())
}

Streamer provides event subscriptions.

Jump to

Keyboard shortcuts

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