heartbeat

package
v0.57.1 Latest Latest
Warning

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

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

Documentation

Overview

Package heartbeat provides functionality for managing heartbeats in external monitoring systems. Supported systems include Cronitor.

Index

Constants

This section is empty.

Variables

View Source
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

type CronitorHeartbeatRepository struct {
	config.Config
	// contains filtered or unexported fields
}

CronitorHeartbeatRepository is a repository for managing heartbeats in Cronitor.

func (*CronitorHeartbeatRepository) CreateOrUpdate

func (r *CronitorHeartbeatRepository) CreateOrUpdate(ctx context.Context) error

func (*CronitorHeartbeatRepository) Delete

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

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

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.

Jump to

Keyboard shortcuts

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