MCPcopy
hub / github.com/kubernetes/client-go / StartEventWatcher

Method StartEventWatcher

tools/record/event.go:264–279  ·  view source on GitHub ↗

StartEventWatcher starts sending events received from this EventBroadcaster to the given event handler function. The return value can be ignored or used to stop recording, if desired.

(eventHandler func(*v1.Event))

Source from the content-addressed store, hash-verified

262// StartEventWatcher starts sending events received from this EventBroadcaster to the given event handler function.
263// The return value can be ignored or used to stop recording, if desired.
264func (eventBroadcaster *eventBroadcasterImpl) StartEventWatcher(eventHandler func(*v1.Event)) watch.Interface {
265 watcher := eventBroadcaster.Watch()
266 go func() {
267 defer utilruntime.HandleCrash()
268 for watchEvent := range watcher.ResultChan() {
269 event, ok := watchEvent.Object.(*v1.Event)
270 if !ok {
271 // This is all local, so there's no reason this should
272 // ever happen.
273 continue
274 }
275 eventHandler(event)
276 }
277 }()
278 return watcher
279}
280
281// NewRecorder returns an EventRecorder that records events with the given event source.
282func (eventBroadcaster *eventBroadcasterImpl) NewRecorder(scheme *runtime.Scheme, source v1.EventSource) EventRecorder {

Callers 2

StartRecordingToSinkMethod · 0.95
StartLoggingMethod · 0.95

Calls 2

WatchMethod · 0.65
ResultChanMethod · 0.45

Tested by

no test coverage detected