diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-04-12 12:19:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-12 12:19:22 +0200 |
commit | 0ee1da50f5e221383c236ccee258cb7592ccabd6 (patch) | |
tree | 08b3798ab08a621920eff4d1f6a3a5f940d3a944 /vendor/k8s.io/apimachinery/pkg/watch/mux.go | |
parent | 669311d8d8a8881571ccc81ce48b9202b15b9def (diff) | |
parent | 14375f35ee00c16327edcd0f5883cc66810fc7db (diff) | |
download | podman-0ee1da50f5e221383c236ccee258cb7592ccabd6.tar.gz podman-0ee1da50f5e221383c236ccee258cb7592ccabd6.tar.bz2 podman-0ee1da50f5e221383c236ccee258cb7592ccabd6.zip |
Merge pull request #9981 from containers/dependabot/go_modules/k8s.io/api-0.21.0
Bump k8s.io/api from 0.20.5 to 0.21.0
Diffstat (limited to 'vendor/k8s.io/apimachinery/pkg/watch/mux.go')
-rw-r--r-- | vendor/k8s.io/apimachinery/pkg/watch/mux.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/vendor/k8s.io/apimachinery/pkg/watch/mux.go b/vendor/k8s.io/apimachinery/pkg/watch/mux.go index 0aaf01adc..e01d51906 100644 --- a/vendor/k8s.io/apimachinery/pkg/watch/mux.go +++ b/vendor/k8s.io/apimachinery/pkg/watch/mux.go @@ -74,6 +74,22 @@ func NewBroadcaster(queueLength int, fullChannelBehavior FullChannelBehavior) *B return m } +// NewLongQueueBroadcaster functions nearly identically to NewBroadcaster, +// except that the incoming queue is the same size as the outgoing queues +// (specified by queueLength). +func NewLongQueueBroadcaster(queueLength int, fullChannelBehavior FullChannelBehavior) *Broadcaster { + m := &Broadcaster{ + watchers: map[int64]*broadcasterWatcher{}, + incoming: make(chan Event, queueLength), + stopped: make(chan struct{}), + watchQueueLength: queueLength, + fullChannelBehavior: fullChannelBehavior, + } + m.distributing.Add(1) + go m.loop() + return m +} + const internalRunFunctionMarker = "internal-do-function" // a function type we can shoehorn into the queue. @@ -198,6 +214,18 @@ func (m *Broadcaster) Action(action EventType, obj runtime.Object) { m.incoming <- Event{action, obj} } +// Action distributes the given event among all watchers, or drops it on the floor +// if too many incoming actions are queued up. Returns true if the action was sent, +// false if dropped. +func (m *Broadcaster) ActionOrDrop(action EventType, obj runtime.Object) bool { + select { + case m.incoming <- Event{action, obj}: + return true + default: + return false + } +} + // Shutdown disconnects all watchers (but any queued events will still be distributed). // You must not call Action or Watch* after calling Shutdown. This call blocks // until all events have been distributed through the outbound channels. Note |