Use a ring channel to avoid blocking write of events (#2082)

* Use a ring channel to avoid blocking write of events

* Add eapache/channels dependency
This commit is contained in:
Manuel Alejandro de Brito Fontes 2018-02-13 17:46:18 -08:00 committed by GitHub
parent 33475b7184
commit 9bcb5b08ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 2833 additions and 78 deletions

26
vendor/github.com/eapache/channels/black_hole_test.go generated vendored Normal file
View file

@ -0,0 +1,26 @@
package channels
import "testing"
func TestBlackHole(t *testing.T) {
discard := NewBlackHole()
for i := 0; i < 1000; i++ {
discard.In() <- i
}
discard.Close()
if discard.Len() != 1000 {
t.Error("blackhole expected 1000 was", discard.Len())
}
// no asserts here, this is just for the race detector's benefit
ch := NewBlackHole()
go ch.Len()
go ch.Cap()
go func() {
ch.In() <- nil
}()
}