MCPcopy Index your code
hub / github.com/coder/coder / NewWatchdogWithClock

Function NewWatchdogWithClock

coderd/database/pubsub/watchdog.go:42–56  ·  view source on GitHub ↗

NewWatchdogWithClock returns a watchdog with the given clock. Product code should always call NewWatchDog.

(ctx context.Context, logger slog.Logger, ps Pubsub, c quartz.Clock)

Source from the content-addressed store, hash-verified

40
41// NewWatchdogWithClock returns a watchdog with the given clock. Product code should always call NewWatchDog.
42func NewWatchdogWithClock(ctx context.Context, logger slog.Logger, ps Pubsub, c quartz.Clock) *Watchdog {
43 ctx, cancel := context.WithCancel(ctx)
44 w := &Watchdog{
45 ctx: ctx,
46 cancel: cancel,
47 logger: logger,
48 ps: ps,
49 timeout: make(chan struct{}),
50 clock: c,
51 }
52 w.wg.Add(2)
53 go w.publishLoop()
54 go w.subscribeMonitor()
55 return w
56}
57
58func (w *Watchdog) Close() error {
59 w.cancel()

Callers 3

TestWatchdog_NoTimeoutFunction · 0.92
TestWatchdog_TimeoutFunction · 0.92
NewWatchdogFunction · 0.85

Calls 3

publishLoopMethod · 0.95
subscribeMonitorMethod · 0.95
AddMethod · 0.65

Tested by 2

TestWatchdog_NoTimeoutFunction · 0.74
TestWatchdog_TimeoutFunction · 0.74