1
0
Fork 0

Don't start a goroutine when flushing buffer

This commit is contained in:
Gregory Eremin 2014-10-05 02:44:40 +04:00
parent 434f980a91
commit 3495977a8d
2 changed files with 2 additions and 11 deletions

View File

@ -66,7 +66,7 @@ func (b *Buffer) Flush() {
return
}
go b.fn(sbuffer)
b.fn(sbuffer)
b.Clear()
}

View File

@ -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")
}