+
+// waitForEvent waits for the channel to receive an event for the specified max timeout.
+// Returns true if waiting timed out.
+func waitForEvent(ch chan eventsapi.EventNotification, timeout time.Duration) (*eventsapi.EventNotification, bool) {
+ select {
+ case event := <-ch:
+ return &event, false // completed normally
+ case <-time.After(timeout):
+ return nil, true // timed out
+ }
+}