Documentation
¶
Overview ¶
Package watchdog provides timeout enforcement for Smith worker processes.
The Watchdog monitors running workers and kills any that exceed the configured smith_timeout. It uses graceful shutdown (context cancellation) first, then forceful kill after a grace period.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TrackedProcess ¶
type TrackedProcess struct {
// WorkerID is the worker's unique identifier.
WorkerID string
// BeadID is the bead being worked on.
BeadID string
// Anvil is the anvil name.
Anvil string
// StartedAt is when the process was started.
StartedAt time.Time
// Cancel cancels the process context (graceful shutdown).
Cancel context.CancelFunc
// Kill forcefully terminates the process.
Kill func() error
// Done returns a channel that closes when the process finishes.
Done func() <-chan struct{}
}
TrackedProcess represents a running process being monitored.
type Watchdog ¶
type Watchdog struct {
// Timeout is the maximum duration a Smith process can run.
Timeout time.Duration
// GracePeriod is how long to wait after context cancellation before killing.
GracePeriod time.Duration
// contains filtered or unexported fields
}
Watchdog monitors running processes and enforces timeouts.
func (*Watchdog) Run ¶
Run starts the watchdog loop. It checks all tracked processes periodically and kills any that have exceeded the timeout. Blocks until ctx is cancelled.
func (*Watchdog) Track ¶
func (w *Watchdog) Track(p *TrackedProcess)
Track adds a process to the watchdog's monitoring list.
func (*Watchdog) TrackedCount ¶
TrackedCount returns the number of currently tracked processes.