mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Address Krasi comments
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
parent
365931ea83
commit
657199af22
|
@ -118,7 +118,7 @@ func NewManager(ctx context.Context, logger log.Logger) *Manager {
|
||||||
discoverCancel: []context.CancelFunc{},
|
discoverCancel: []context.CancelFunc{},
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
updatert: 5 * time.Second,
|
updatert: 5 * time.Second,
|
||||||
trigger: make(chan struct{}, 1),
|
triggerSend: make(chan struct{}, 1),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,13 +142,13 @@ type Manager struct {
|
||||||
// should only be modified in unit tests.
|
// should only be modified in unit tests.
|
||||||
updatert time.Duration
|
updatert time.Duration
|
||||||
|
|
||||||
// The trigger channel signals to the manager that new updates have been received from providers.
|
// The triggerSend channel signals to the manager that new updates have been received from providers.
|
||||||
trigger chan struct{}
|
triggerSend chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run starts the background processing
|
// Run starts the background processing
|
||||||
func (m *Manager) Run() error {
|
func (m *Manager) Run() error {
|
||||||
go m.sendUpdates()
|
go m.sender()
|
||||||
for range m.ctx.Done() {
|
for range m.ctx.Done() {
|
||||||
m.cancelDiscoverers()
|
m.cancelDiscoverers()
|
||||||
return m.ctx.Err()
|
return m.ctx.Err()
|
||||||
|
@ -216,14 +216,14 @@ func (m *Manager) updater(ctx context.Context, p *provider, updates chan []*targ
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case m.trigger <- struct{}{}:
|
case m.triggerSend <- struct{}{}:
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) sendUpdates() {
|
func (m *Manager) sender() {
|
||||||
ticker := time.NewTicker(m.updatert)
|
ticker := time.NewTicker(m.updatert)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ func (m *Manager) sendUpdates() {
|
||||||
return
|
return
|
||||||
case <-ticker.C: // Some discoverers send updates too often so we throttle these with the ticker.
|
case <-ticker.C: // Some discoverers send updates too often so we throttle these with the ticker.
|
||||||
select {
|
select {
|
||||||
case <-m.trigger:
|
case <-m.triggerSend:
|
||||||
sentUpdates.Inc()
|
sentUpdates.Inc()
|
||||||
select {
|
select {
|
||||||
case m.syncCh <- m.allGroups():
|
case m.syncCh <- m.allGroups():
|
||||||
|
@ -241,7 +241,7 @@ func (m *Manager) sendUpdates() {
|
||||||
delayedUpdates.Inc()
|
delayedUpdates.Inc()
|
||||||
level.Debug(m.logger).Log("msg", "discovery receiver's channel was full so will retry the next cycle")
|
level.Debug(m.logger).Log("msg", "discovery receiver's channel was full so will retry the next cycle")
|
||||||
select {
|
select {
|
||||||
case m.trigger <- struct{}{}:
|
case m.triggerSend <- struct{}{}:
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue