watchdog

package
v0.33.13 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package watchdog forces process exit when the worker heartbeat goes flat with active workload, letting the platform's restart policy recover from latent Go-side wedges (blocked pipe, mutex deadlock, exhausted resource pool).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, hb *Heartbeat, opts Options)

Types

type Heartbeat

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

func (*Heartbeat) Read

func (h *Heartbeat) Read() uint64

func (*Heartbeat) Tick

func (h *Heartbeat) Tick()

Lock-free; safe from hot paths.

type Options

type Options struct {
	// Defaults: 90s / 15s / 2m.
	StallThreshold time.Duration
	CheckInterval  time.Duration
	GracePeriod    time.Duration

	// HasWork=nil → assume work always exists. Returning false skips
	// the staleness check (no jobs alive → can't be wedged).
	HasWork func(ctx context.Context) bool

	Logger *slog.Logger
	// Tests substitute a non-fatal handler. Default os.Exit.
	Exit func(code int)
}

Jump to

Keyboard shortcuts

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