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:
parent
33475b7184
commit
9bcb5b08ea
35 changed files with 2833 additions and 78 deletions
26
vendor/github.com/eapache/channels/black_hole_test.go
generated
vendored
Normal file
26
vendor/github.com/eapache/channels/black_hole_test.go
generated
vendored
Normal 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
|
||||
}()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue