0.2.71
This commit is contained in:
@@ -95,6 +95,7 @@ type Service struct {
|
||||
behaviour BehaviourSource
|
||||
load LoadGauge
|
||||
log *slog.Logger
|
||||
paused func() bool
|
||||
cfg Config
|
||||
cfgMu sync.RWMutex
|
||||
|
||||
@@ -109,6 +110,9 @@ type Service struct {
|
||||
liveDelay time.Duration
|
||||
}
|
||||
|
||||
// SetPaused installs the server-wide quiet-time gate before Run starts.
|
||||
func (s *Service) SetPaused(paused func() bool) { s.paused = paused }
|
||||
|
||||
func New(deps Deps) *Service {
|
||||
cfg := NormaliseConfig(deps.Config)
|
||||
detector := deps.Detector
|
||||
@@ -312,6 +316,12 @@ func (s *Service) Run(ctx context.Context) {
|
||||
if ctx.Err() != nil {
|
||||
return
|
||||
}
|
||||
if s.paused != nil && s.paused() {
|
||||
if !sleep(ctx, idlePoll) {
|
||||
return
|
||||
}
|
||||
continue
|
||||
}
|
||||
candidate, found := s.queue.Claim()
|
||||
if !found {
|
||||
if !sleep(ctx, idlePoll) {
|
||||
|
||||
Reference in New Issue
Block a user