heartbeat

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Key

func Key(keyPrefix, instanceID string) string

Key returns the Redis key for a given instance ID.

func Run

func Run(ctx context.Context, cfg Config)

Run publishes a heartbeat to Redis every 10 seconds. It deletes the instance key on context cancellation (clean shutdown).

Types

type Config

type Config struct {
	InstanceID string
	Client     *redis.Client
	KeyPrefix  string
	Hostname   string
	Listeners  []config.ListenerConfig
	StatsFunc  func() Stats
	Logger     *slog.Logger
}

Config configures the heartbeat publisher.

type RedactedListener added in v0.6.8

type RedactedListener struct {
	Name        string `json:"name"`
	Listen      string `json:"listen"`
	Mode        string `json:"mode"`
	Backend     string `json:"backend"`
	Advertise   string `json:"advertise,omitempty"`
	BackendTLS  bool   `json:"tls"`
	Provisioner string `json:"provisioner,omitempty"` // "postgres" | "mongodb" | ""
}

RedactedListener is the subset of config.ListenerConfig that is safe to publish in the heartbeat. It deliberately omits all admin credential blocks (Postgres/MongoDB admin passwords, static-user passwords); only the provisioner kind is surfaced.

type Stats

type Stats struct {
	ActiveConns  int64
	TotalConns   int64
	BytesRead    int64
	BytesWritten int64
}

Stats holds runtime statistics for an instance.

Jump to

Keyboard shortcuts

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