mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-11 06:02:18 +00:00
Add a unit test for watch.Broadcaster DropIfChannelFull and a couple small fixes
This commit is contained in:
@@ -27,10 +27,15 @@ import (
|
||||
type FullChannelBehavior int
|
||||
|
||||
const (
|
||||
WaitIfChannelFull = iota
|
||||
DropIfChannelFull = iota
|
||||
WaitIfChannelFull FullChannelBehavior = iota
|
||||
DropIfChannelFull
|
||||
)
|
||||
|
||||
// Buffer the incoming queue a little bit even though it should rarely ever accumulate
|
||||
// anything, just in case a few events are received in such a short window that
|
||||
// Broadcaster can't move them onto the watchers' queues fast enough.
|
||||
const incomingQueueLength = 25
|
||||
|
||||
// Broadcaster distributes event notifications among any number of watchers. Every event
|
||||
// is delivered to every watcher.
|
||||
type Broadcaster struct {
|
||||
@@ -58,7 +63,7 @@ type Broadcaster struct {
|
||||
func NewBroadcaster(queueLength int, fullChannelBehavior FullChannelBehavior) *Broadcaster {
|
||||
m := &Broadcaster{
|
||||
watchers: map[int64]*broadcasterWatcher{},
|
||||
incoming: make(chan Event),
|
||||
incoming: make(chan Event, incomingQueueLength),
|
||||
watchQueueLength: queueLength,
|
||||
fullChannelBehavior: fullChannelBehavior,
|
||||
}
|
||||
|
Reference in New Issue
Block a user