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)
| 40 | |
| 41 | // NewWatchdogWithClock returns a watchdog with the given clock. Product code should always call NewWatchDog. |
| 42 | func 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 | |
| 58 | func (w *Watchdog) Close() error { |
| 59 | w.cancel() |