selfheartbeat

package
v1.5.12 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package selfheartbeat sends an outbound ping so an external monitor can page when the control plane itself goes silent.

Index

Constants

View Source
const (
	EnvTimeout  = "APP_SELF_HEARTBEAT_TIMEOUT"
	EnvLogEvery = "APP_SELF_HEARTBEAT_LOG_EVERY"
)

Env names for the fixed bounds; the URL and interval are live runtime settings.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Timeout  time.Duration
	LogEvery time.Duration
}

Config bounds one request and the failure log rate.

func ConfigFromEnv

func ConfigFromEnv(lookup func(string) (string, bool)) Config

ConfigFromEnv reads the tunables; bad values fall back to defaults.

type Pinger

type Pinger struct {
	// contains filtered or unexported fields
}

Pinger sends the heartbeat GET.

func New

func New(cfg Config, set Settings, log *slog.Logger) *Pinger

New builds a Pinger on the SSRF-guarded client; call Run to start it.

func (*Pinger) Interval

func (p *Pinger) Interval(ctx context.Context) time.Duration

Interval is the live ping interval, clamped to the setting's range.

func (*Pinger) Poll

func (p *Pinger) Poll(ctx context.Context)

Poll pings when the interval has elapsed since the last ping; with no URL it does nothing.

func (*Pinger) Run

func (p *Pinger) Run(ctx context.Context)

Run polls the settings every few seconds and pings once the live interval has elapsed.

func (*Pinger) Tick

func (p *Pinger) Tick(ctx context.Context)

Tick sends one ping. With no URL set it makes no request.

type Settings

type Settings interface {
	String(ctx context.Context, key string) string
	Int(ctx context.Context, key string) int
}

Settings reads live runtime settings; *runtimesettings.Service satisfies it.

Jump to

Keyboard shortcuts

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