diff --git a/buffer.go b/buffer.go index 7737593..1a2f04f 100644 --- a/buffer.go +++ b/buffer.go @@ -57,15 +57,15 @@ func (b *Buffer) Add(series ...*influxdb.Series) { // Flushes aggregated series into database func (b *Buffer) Flush() { + if len(b.series) == 0 { + return + } + sbuffer := []*influxdb.Series{} for _, item := range b.series { sbuffer = append(sbuffer, item) } - if len(sbuffer) == 0 { - return - } - b.fn(sbuffer) b.Clear() }