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, ids ...string) error
- func (db *DB) FindAllByService(ctx context.Context, serviceID string) ([]Monitor, error)
- func (db *DB) FindMany(ctx context.Context, ids ...string) ([]Monitor, error)
- func (db *DB) FindOneTx(ctx context.Context, tx *sql.Tx, id string) (*Monitor, error)
- func (db *DB) Heartbeat(ctx context.Context, id string) error
- func (db *DB) UpdateTx(ctx context.Context, tx *sql.Tx, 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"` Timeout time.Duration `json:"timeout,omitempty"` // contains filtered or unexported fields }
A Monitor will generate an alert if it does not receive a heartbeat within the configured TimeoutMinutes.
func (Monitor) LastHeartbeat ¶ added in v0.24.0
LastHeartbeat returns the timestamp of the last successful heartbeat.
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) // UpdateTx updates a heartbeat's fields within the transaction. UpdateTx(context.Context, *sql.Tx, *Monitor) error // FindOneTx returns a heartbeat montior for updating. FindOneTx(context.Context, *sql.Tx, string) (*Monitor, error) // FindMany returns the heartbeat monitors with the given IDs. FindMany(context.Context, ...string) ([]Monitor, error) }
Store manages heartbeat checks and recording heartbeats.
Click to show internal directories.
Click to hide internal directories.