Check if buffer is empty _before_ rebuilding it
This commit is contained in:
parent
9d4e937aef
commit
49e0fc5a05
|
@ -57,15 +57,15 @@ func (b *Buffer) Add(series ...*influxdb.Series) {
|
||||||
|
|
||||||
// Flushes aggregated series into database
|
// Flushes aggregated series into database
|
||||||
func (b *Buffer) Flush() {
|
func (b *Buffer) Flush() {
|
||||||
|
if len(b.series) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
sbuffer := []*influxdb.Series{}
|
sbuffer := []*influxdb.Series{}
|
||||||
for _, item := range b.series {
|
for _, item := range b.series {
|
||||||
sbuffer = append(sbuffer, item)
|
sbuffer = append(sbuffer, item)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(sbuffer) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
b.fn(sbuffer)
|
b.fn(sbuffer)
|
||||||
b.Clear()
|
b.Clear()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue