Documentation
¶
Index ¶
- type DB
- func (db *DB) CreateTx(ctx context.Context, tx *sql.Tx, m *Monitor) (*Monitor, error)
- func (db *DB) DeleteTx(ctx context.Context, tx *sql.Tx, id string) error
- func (db *DB) FindAllByService(ctx context.Context, serviceID string) ([]Monitor, error)
- func (db *DB) Heartbeat(ctx context.Context, id string) error
- func (db *DB) Update(ctx context.Context, m *Monitor) error
- type Monitor
- type State
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB implements Store using Postgres as a backend.
func (*DB) FindAllByService ¶
type Monitor ¶
type Monitor struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
ServiceID string `json:"service_id,omitempty"`
IntervalMinutes int `json:"interval_minutes,omitempty"`
// contains filtered or unexported fields
}
A Monitor will generate an alert if it does not receive a heartbeat within the configured IntervalMinutes.
func (Monitor) LastHeartbeatMinutes ¶
LastHeartbeatMinutes returns the minutes since the heartbeat last reported. The interval is truncated, so a value of 0 means "less than 1 minute".
type State ¶
type State string
State represents the health of a heartbeat monitor.
const ( // StateInactive means the heartbeat has not yet reported for the first time. StateInactive State = "inactive" // StateHealthy indicates a heartbeat was received within the past interval. StateHealthy State = "healthy" // StateUnhealthy indicates a heartbeat has not been received since beyond the interval. StateUnhealthy State = "unhealthy" )
type Store ¶
type Store interface {
// Heartbeat records a heartbeat for the given heartbeat ID.
Heartbeat(context.Context, string) error
// CreateTx creates a new heartbeat check within the transaction.
CreateTx(context.Context, *sql.Tx, *Monitor) (*Monitor, error)
// Delete deletes the heartbeat check with the given heartbeat ID.
DeleteTx(context.Context, *sql.Tx, string) error
// FindAllByService returns all heartbeats belonging to the given service ID.
FindAllByService(context.Context, string) ([]Monitor, error)
}
Store manages heartbeat checks and recording heartbeats.
Click to show internal directories.
Click to hide internal directories.