Help us shape the future of Go! Take the 2026 Go Developer Survey

watchdog

package
v0.7.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IdleStatus

type IdleStatus int
const (
	IdleStatusBornIdle IdleStatus = iota
	IdleStatusIdle
	IdleStatusNotIdle
)

type Watchdog

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

func NewWatchdog

func NewWatchdog(
	idleTimeout, bornIdleTimeout, offlineTimeout, consideredLostTimeout, tickerInterval time.Duration,
	updateWorker func(workerID int32, newStatus string) error,
	deleteWorker func(workerID int32) error,
	warmCheck func(workerID int32) (bool, time.Duration),
	db *sql.DB,
) *Watchdog

func (*Watchdog) RebuildFromWorkers

func (w *Watchdog) RebuildFromWorkers(workers []WorkerInfo)

func (*Watchdog) ResyncActiveTasks added in v0.7.1

func (w *Watchdog) ResyncActiveTasks(ctx context.Context, db *sql.DB)

ResyncActiveTasks re-queries the DB for the current active task counts and fixes up any drift caused by TaskFinished calls that arrived between the initial FetchWorkersForWatchdog query and RebuildFromWorkers.

func (*Watchdog) Run

func (w *Watchdog) Run(stopChan <-chan struct{})

Main watchdog loop

func (*Watchdog) SetPermanent added in v0.7.4

func (w *Watchdog) SetPermanent(workerID int32, isPermanent bool)

SetPermanent updates the cached permanent flag for a worker.

func (*Watchdog) TaskAccepted

func (w *Watchdog) TaskAccepted(workerID int32)

Called when a worker accepts a task (Assigned ➔ Accepted)

func (*Watchdog) TaskFinished

func (w *Watchdog) TaskFinished(workerID int32)

Called when a worker finishes a task (Success or Failure)

func (*Watchdog) WorkerDeleted

func (w *Watchdog) WorkerDeleted(workerID int32)

WorkerDeleted should be called when a worker is deleted from the database

func (*Watchdog) WorkerPinged

func (w *Watchdog) WorkerPinged(workerID int32)

Called when a worker sends a ping

func (*Watchdog) WorkerRegistered

func (w *Watchdog) WorkerRegistered(workerID int32, isPermanent bool)

Called when a worker is registered (comes online and is running)

func (*Watchdog) WorkerSpawned

func (w *Watchdog) WorkerSpawned(workerID int32, isPermanent bool)

Called right after we create the DB row + cloud deploy job, before the worker is ready

type WorkerInfo

type WorkerInfo struct {
	WorkerID    int32
	Status      string
	IsPermanent bool
	ActiveTasks int
	LastNotIdle *time.Time
}

Jump to

Keyboard shortcuts

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