mirror of
https://github.com/prometheus/prometheus
synced 2024-12-26 00:23:18 +00:00
Code Review: Last replacement wins.
This commit is contained in:
parent
9cde48754b
commit
d4db3cf00b
@ -26,7 +26,7 @@ const (
|
||||
intervalKey = "interval"
|
||||
|
||||
targetAddQueueSize = 100
|
||||
targetReplaceQueueSize = 100
|
||||
targetReplaceQueueSize = 1
|
||||
)
|
||||
|
||||
type TargetPool struct {
|
||||
@ -82,7 +82,16 @@ func (p *TargetPool) addTarget(target Target) {
|
||||
}
|
||||
|
||||
func (p *TargetPool) ReplaceTargets(newTargets []Target) {
|
||||
p.replaceTargetsQueue <- newTargets
|
||||
p.Lock()
|
||||
defer p.Unlock()
|
||||
|
||||
// If there is anything remaining in the queue for effectuation, clear it out,
|
||||
// because the last mutation should win.
|
||||
select {
|
||||
case <-p.replaceTargetsQueue:
|
||||
default:
|
||||
p.replaceTargetsQueue <- newTargets
|
||||
}
|
||||
}
|
||||
|
||||
func (p *TargetPool) replaceTargets(newTargets []Target) {
|
||||
|
Loading…
Reference in New Issue
Block a user