Documentation
¶
Overview ¶
Package heartbeat provides functionality for managing heartbeats in external monitoring systems. Supported systems include Cronitor.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMonitorNotFound is returned when a monitor does not exist in Cronitor. ErrMonitorNotFound = errors.New("monitor not found") )
Functions ¶
This section is empty.
Types ¶
type CronitorHeartbeatRepository ¶
CronitorHeartbeatRepository is a repository for managing heartbeats in Cronitor.
func (*CronitorHeartbeatRepository) CreateOrUpdate ¶
func (r *CronitorHeartbeatRepository) CreateOrUpdate(ctx context.Context) error
type CronitorMonitor ¶
type CronitorMonitor struct {
Type string `json:"type"`
Key string `json:"key"`
Name string `json:"name"`
GraceSeconds int `json:"grace_seconds"`
Schedule string `json:"schedule"`
Notify []string `json:"notify"`
Tags []string `json:"tags"`
Note string `json:"note,omitempty"`
FailureTolerance *int `json:"failure_tolerance,omitempty"`
RealertInterval string `json:"realert_interval,omitempty"`
}
CronitorMonitor represents a Cronitor heartbeat monitor configuration.
type HTTPClient ¶
HTTPClient is an interface for making HTTP requests, allowing for easier testing.
type HeartbeatRepository ¶
type HeartbeatRepository interface {
// CreateOrUpdate creates or updates the heartbeat for the management cluster.
CreateOrUpdate(ctx context.Context) error
// Delete deletes the heartbeat for the management cluster.
Delete(ctx context.Context) error
}
HeartbeatRepository is the interface for the heartbeat repository. It provides methods to create or update and delete a heartbeat. The heartbeat is used by the monitoring system to detect if the management cluster is alive. The current implementation relies on Cronitor.io but other implementations can be added in the future.
func NewCronitorHeartbeatRepository ¶
func NewCronitorHeartbeatRepository(cfg config.Config, httpClient HTTPClient) (HeartbeatRepository, error)
NewCronitorHeartbeatRepository creates a new CronitorHeartbeatRepository.