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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
go b.fn(sbuffer)
|
b.fn(sbuffer)
|
||||||
b.Clear()
|
b.Clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,20 +34,11 @@ func TestAdd(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFlush(t *testing.T) {
|
func TestFlush(t *testing.T) {
|
||||||
res := make(chan []*influxdb.Series, 1)
|
fn := func(series []*influxdb.Series) {}
|
||||||
fn := func(series []*influxdb.Series) { res <- series }
|
|
||||||
b := NewBuffer(1, fn)
|
b := NewBuffer(1, fn)
|
||||||
defer b.Close()
|
defer b.Close()
|
||||||
b.Add(&influxdb.Series{})
|
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 {
|
if b.Size() != 0 {
|
||||||
t.Error("Flushing buffer does not make it empty again")
|
t.Error("Flushing buffer does not make it empty again")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue