Merge pull request #125472 from karlkfi/karl-watch-comments
Add details to watch interface method comments
This commit is contained in:
@@ -27,13 +27,25 @@ import (
|
|||||||
|
|
||||||
// Interface can be implemented by anything that knows how to watch and report changes.
|
// Interface can be implemented by anything that knows how to watch and report changes.
|
||||||
type Interface interface {
|
type Interface interface {
|
||||||
// Stop stops watching. Will close the channel returned by ResultChan(). Releases
|
// Stop tells the producer that the consumer is done watching, so the
|
||||||
// any resources used by the watch.
|
// producer should stop sending events and close the result channel. The
|
||||||
|
// consumer should keep watching for events until the result channel is
|
||||||
|
// closed.
|
||||||
|
//
|
||||||
|
// Because some implementations may create channels when constructed, Stop
|
||||||
|
// must always be called, even if the consumer has not yet called
|
||||||
|
// ResultChan().
|
||||||
|
//
|
||||||
|
// Only the consumer should call Stop(), not the producer. If the producer
|
||||||
|
// errors and needs to stop the watch prematurely, it should instead send
|
||||||
|
// an error event and close the result channel.
|
||||||
Stop()
|
Stop()
|
||||||
|
|
||||||
// ResultChan returns a chan which will receive all the events. If an error occurs
|
// ResultChan returns a channel which will receive events from the event
|
||||||
// or Stop() is called, the implementation will close this channel and
|
// producer. If an error occurs or Stop() is called, the producer must
|
||||||
// release any resources used by the watch.
|
// close this channel and release any resources used by the watch.
|
||||||
|
// Closing the result channel tells the consumer that no more events will be
|
||||||
|
// sent.
|
||||||
ResultChan() <-chan Event
|
ResultChan() <-chan Event
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ type Lister interface {
|
|||||||
// Watcher is any object that knows how to start a watch on a resource.
|
// Watcher is any object that knows how to start a watch on a resource.
|
||||||
type Watcher interface {
|
type Watcher interface {
|
||||||
// Watch should begin a watch at the specified version.
|
// Watch should begin a watch at the specified version.
|
||||||
|
//
|
||||||
|
// If Watch returns an error, it should handle its own cleanup, including
|
||||||
|
// but not limited to calling Stop() on the watch, if one was constructed.
|
||||||
|
// This allows the caller to ignore the watch, if the error is non-nil.
|
||||||
Watch(options metav1.ListOptions) (watch.Interface, error)
|
Watch(options metav1.ListOptions) (watch.Interface, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user