mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2024-11-13 02:41:23 +00:00
Event queue processes and filling race.
We send the slice off to be process, but potentially start overwriting the previous content straight away. Just start again with a fresh slice. Fixes #247 Signed-off-by: Tristan Colgate <tristan@qubit.com>
This commit is contained in:
parent
e60f2f147b
commit
49296e321e
1 changed files with 2 additions and 1 deletions
3
event.go
3
event.go
|
@ -82,6 +82,7 @@ func newEventQueue(c chan Events, flushThreshold int, flushInterval time.Duratio
|
|||
c: c,
|
||||
flushThreshold: flushThreshold,
|
||||
flushTicker: ticker,
|
||||
q: make([]Event, 0, flushThreshold),
|
||||
}
|
||||
go func() {
|
||||
for {
|
||||
|
@ -112,7 +113,7 @@ func (eq *eventQueue) flush() {
|
|||
|
||||
func (eq *eventQueue) flushUnlocked() {
|
||||
eq.c <- eq.q
|
||||
eq.q = eq.q[:0]
|
||||
eq.q = make([]Event, 0, cap(eq.q))
|
||||
eventsFlushed.Inc()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue