Don't start a goroutine when flushing buffer
This commit is contained in:
parent
434f980a91
commit
3495977a8d
|
@ -66,7 +66,7 @@ func (b *Buffer) Flush() {
|
|||
return
|
||||
}
|
||||
|
||||
go b.fn(sbuffer)
|
||||
b.fn(sbuffer)
|
||||
b.Clear()
|
||||
}
|
||||
|
||||
|
|
|
@ -34,20 +34,11 @@ func TestAdd(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestFlush(t *testing.T) {
|
||||
res := make(chan []*influxdb.Series, 1)
|
||||
fn := func(series []*influxdb.Series) { res <- series }
|
||||
fn := func(series []*influxdb.Series) {}
|
||||
b := NewBuffer(1, fn)
|
||||
defer b.Close()
|
||||
b.Add(&influxdb.Series{})
|
||||
|
||||
timer := time.NewTimer(time.Second)
|
||||
|
||||
select {
|
||||
case <-res:
|
||||
case <-timer.C:
|
||||
t.Error("Flushing did not happen")
|
||||
}
|
||||
|
||||
if b.Size() != 0 {
|
||||
t.Error("Flushing buffer does not make it empty again")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue