0.2.71
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user