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
@@ -65,6 +65,7 @@ type Dispatcher struct {
transports map[string]Transport
queue chan job
paused func() bool
mu sync.Mutex
cached store.IntegrationSettings
@@ -76,6 +77,9 @@ type Dispatcher struct {
dropped int64
}
// SetPaused installs the server-wide quiet-time gate before Start is called.
func (d *Dispatcher) SetPaused(paused func() bool) { d.paused = paused }
func New(st *store.Store, log *slog.Logger, events *adminevents.Bus) *Dispatcher {
dispatcher := &Dispatcher{
store: st, log: log.With("component", "integrations"), events: events,
@@ -101,6 +105,15 @@ func (d *Dispatcher) Start(ctx context.Context) {
case <-ctx.Done():
return
case work := <-d.queue:
for d.paused != nil && d.paused() {
timer := time.NewTimer(30 * time.Second)
select {
case <-ctx.Done():
timer.Stop()
return
case <-timer.C:
}
}
d.deliver(ctx, work)
}
}