This commit is contained in:
ponzischeme89
2026-08-17 07:34:23 +12:00
parent 93fb0fd728
commit 36cb1324fd
56 changed files with 1177 additions and 168 deletions
+10
View File
@@ -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) {