mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
Export ErrWatchClosed from watch.Until
This is needed so that users of watch.Until may check for this particular error instead of attempting to match the error string. ```release-note NONE ```
This commit is contained in:
parent
079020f559
commit
505a7e935d
@ -29,8 +29,8 @@ import (
|
|||||||
// from false to true).
|
// from false to true).
|
||||||
type ConditionFunc func(event Event) (bool, error)
|
type ConditionFunc func(event Event) (bool, error)
|
||||||
|
|
||||||
// errWatchClosed is returned when the watch channel is closed before timeout in Until.
|
// ErrWatchClosed is returned when the watch channel is closed before timeout in Until.
|
||||||
var errWatchClosed = errors.New("watch closed before Until timeout")
|
var ErrWatchClosed = errors.New("watch closed before Until timeout")
|
||||||
|
|
||||||
// Until reads items from the watch until each provided condition succeeds, and then returns the last watch
|
// Until reads items from the watch until each provided condition succeeds, and then returns the last watch
|
||||||
// encountered. The first condition that returns an error terminates the watch (and the event is also returned).
|
// encountered. The first condition that returns an error terminates the watch (and the event is also returned).
|
||||||
@ -65,7 +65,7 @@ func Until(timeout time.Duration, watcher Interface, conditions ...ConditionFunc
|
|||||||
select {
|
select {
|
||||||
case event, ok := <-ch:
|
case event, ok := <-ch:
|
||||||
if !ok {
|
if !ok {
|
||||||
return lastEvent, errWatchClosed
|
return lastEvent, ErrWatchClosed
|
||||||
}
|
}
|
||||||
lastEvent = &event
|
lastEvent = &event
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user