infra/op-conductor-mon/pkg/monitor/scheduler.go
felipe 28bb7461e9
feat: op-conductor-mon (#1)
* feat: op-conductor-mon

* Update CODEOWNERS
2024-05-24 14:34:07 -07:00

23 lines
315 B
Go

package monitor
import (
"context"
"time"
)
func schedule(ctx context.Context, interval time.Duration, handler func(ctx context.Context)) {
go func() {
for {
timer := time.NewTimer(interval)
handler(ctx)
select {
case <-timer.C:
case <-ctx.Done():
timer.Stop()
return
}
}
}()
}