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))
| 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. |
| 264 | func (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. |
| 282 | func (eventBroadcaster *eventBroadcasterImpl) NewRecorder(scheme *runtime.Scheme, source v1.EventSource) EventRecorder { |
no test coverage detected