func()

in readers/apiserver/watchlist/internal/watchlist/watchlist.go [276:298]


func (r *Reader) startWatch(ctx context.Context, cancel context.CancelFunc, rt RetrieveType) error {
	finished := make(chan struct{})
	timer := time.After(30 * time.Second)

	go func() {
		select {
		case <-finished:
		case <-timer:
			cancel()
		}
	}()

	spanWatchers := rtMap[rt](ctx)

	if err := r.watch(ctx, rt, spanWatchers); err != nil {
		return fmt.Errorf("error starting namespace watcher: %v", err)
	}
	if ctx.Err() != nil {
		return fmt.Errorf("error starting namespace watcher: could not connect to server in time")
	}
	close(finished)
	return ctx.Err()
}