Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHistoryMetrics ¶ added in v0.14.2
func NewHistoryMetrics(store Store) prometheus.Collector
NewHistoryMetrics returns a Prometheus collector that tracks the size of the history store.
Types ¶
type BackendType ¶ added in v0.14.1
type BackendType string
var BackendTypeRingStore BackendType = "ring"
type Event ¶
type Event struct {
Timestamp time.Time `json:"timestamp"` // when it happened
Type EventType `json:"type"` // what kind of event
HeartbeatID string `json:"heartbeat_id"` // which heartbeat it belongs to
RawPayload json.RawMessage `json:"payload,omitempty"` // optional payload
}
Event is a generic record of something that happened.
func MustNewEvent ¶ added in v0.14.1
MustNewEvent creates a new Event or panics if payload marshalling fails.
func (*Event) DecodePayload ¶ added in v0.14.1
DecodePayload unmarshals the raw payload into the given target.
type EventType ¶
type EventType string
EventType categorizes what happened.
const ( EventTypeHeartbeatReceived EventType = "HeartbeatReceived" // a ping from a client EventTypeHeartbeatFailed EventType = "HeartbeatFailed" // a manual failure EventTypeStateChanged EventType = "StateChanged" // state transition of an actor EventTypeNotificationSent EventType = "NotificationSent" // a notification was sent EventTypeNotificationFailed EventType = "NotificationFailed" // a notification failed )
type MockStore ¶ added in v0.14.1
type MockStore struct {
RecordEventFunc func(context.Context, Event) error
GetEventsFunc func() []Event
GetEventsByIDFunc func(string) []Event
ByteSizeFunc func() int
}
type NotificationPayload ¶ added in v0.14.1
type NotificationPayload struct {
Receiver string `json:"receiver"` // receiver ID
Type string `json:"type"` // notifier type (e.g., slack, msteams)
Target string `json:"target"` // target destination
Error string `json:"error,omitempty"` // optional error message
}
NotificationPayload is used for NotificationSent and NotificationFailed events.
type RequestMetadataPayload ¶ added in v0.14.1
type RequestMetadataPayload struct {
Source string `json:"source"` // remote IP address
Method string `json:"method"` // HTTP method
UserAgent string `json:"user_agent"` // user-agent header
}
RequestMetadataPayload is used for HeartbeatReceived and HeartbeatFailed events.
type RingStore ¶
type RingStore struct {
// contains filtered or unexported fields
}
RingStore is a fixed-size circular buffer of history.Event. When full, new events overwrite the oldest one.
func NewRingStore ¶
NewRingStore returns a RingStore that holds at most maxEvents.
func (*RingStore) ByteSize ¶ added in v0.14.2
ByteSize returns an estimated size of the ring buffer in bytes.
type StateChangePayload ¶ added in v0.14.1
type StateChangePayload struct {
From string `json:"from"` // previous state
To string `json:"to"` // new state
}
StateChangePayload is used for StateChanged events.
type Store ¶
type Store interface {
Append(ctx context.Context, e Event) error // Append appends a new event to history.
List() []Event // List returns a snapshot of all recorded events.
ListByID(id string) []Event // ListByID returns all events recorded for the specified heartbeat ID.
ByteSize() int // ByteSize returns the current size of the history store in bytes.
}
Store records and exposes all system events.