common

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: AGPL-3.0, AGPL-3.0-only Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultDeleteTimeout bounds pod-termination / PVC-detach waits.
	DefaultDeleteTimeout = 300
	// DefaultHealTimeout bounds a node heal / cluster-rejoin wait.
	DefaultHealTimeout = 600
)

Default operation timeouts, in seconds, used when the config leaves them unset.

View Source
const EnvPrefix = "HASTEWARD_"

Variables

This section is empty.

Functions

func DebugLog

func DebugLog(format string, args ...any)

func DisableSleepForTest added in v0.2.0

func DisableSleepForTest() (restore func())

DisableSleepForTest makes Sleep a no-op (poll loops run instantly) and returns a restore func. TEST-ONLY.

func Env

func Env(key, fallback string) string

Env reads HASTEWARD_<KEY> from the environment with a fallback default.

func EnvBool

func EnvBool(key string, fallback bool) bool

EnvBool reads HASTEWARD_<KEY> as a boolean. Accepts "1", "t", "true", "yes", "on" (case-insensitive).

func EnvInt

func EnvInt(key string, fallback int) int

EnvInt reads HASTEWARD_<KEY> as an integer with a fallback default.

func EnvRaw

func EnvRaw(key, fallback string) string

EnvRaw reads a raw environment variable (no prefix) with a fallback default. Used for standard env vars like KUBECONFIG that don't use the HASTEWARD_ prefix.

func ErrorLog

func ErrorLog(format string, args ...any)

func FatalLog

func FatalLog(format string, args ...any)

func InfoLog

func InfoLog(format string, args ...any)

func InitLogging

func InitLogging(jsonMode bool)

InitLogging sets up the slog-based logging system. jsonMode=true uses JSONHandler (for serve mode), false uses TextHandler (for CLI).

func Ptr added in v0.2.0

func Ptr[T any](v T) *T

Ptr returns a pointer to v — handy for the many optional/pointer fields in the Kubernetes API types (GracePeriodSeconds, Replicas, …).

func RegisterSecret

func RegisterSecret(value string)

RegisterSecret adds a value to be redacted from all log output.

func SetSleepForTest added in v0.2.0

func SetSleepForTest(fn func(time.Duration)) (restore func())

SetSleepForTest replaces Sleep and returns a restore func. TEST-ONLY.

func Sleep added in v0.2.0

func Sleep(d time.Duration)

Sleep pauses for d. Production code in poll loops should call this instead of time.Sleep so flow tests can drive the loops instantly.

func WarnLog

func WarnLog(format string, args ...any)

Types

type Config

type Config struct {
	Engine         string
	ClusterName    string
	Namespace      string
	Mode           string
	InstanceNumber *int
	DonorInstance  *int // Explicit donor ordinal for forced repair (declares authoritative source)
	Force          bool
	WipeDatadir    bool // Wipe entire datadir (not just grastate) — forces full SST reseed from donor
	FixBootstrap   bool // Reconfigure: clear grastate + remove bootstrap config on target instance
	BackupsPath    string
	NoEscrow       bool
	Unwedge        bool // --unwedge: enable the CNPG disk-full deadlock breaker (escrow-gated offline datadir clear)
	BackupMethod   string
	Snapshot       string // Restic snapshot ID or "latest" (for restore)
	ResticPassword string // Restic repository encryption password
	HealTimeout    int
	DeleteTimeout  int
	Kubeconfig     string
	Verbose        bool
	DryRun         bool // preview destructive actions without executing (set from --dry-run)
}

Config holds all runtime configuration for a hasteward run.

type EventSink

type EventSink interface {
	Info(msg string, fields ...any)
	Warn(msg string, fields ...any)
	Progress(operation string, current, total int64)
	Step(name string, status string)
}

EventSink receives progress events from engine operations. Implementations format these for CLI output, slog, metrics, etc.

type NopEventSink

type NopEventSink struct{}

NopEventSink discards all events.

func (NopEventSink) Info

func (NopEventSink) Info(string, ...any)

func (NopEventSink) Progress

func (NopEventSink) Progress(string, int64, int64)

func (NopEventSink) Step

func (NopEventSink) Step(string, string)

func (NopEventSink) Warn

func (NopEventSink) Warn(string, ...any)

Jump to

Keyboard shortcuts

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