Documentation ¶
Index ¶
- Variables
- func WatchCount(onlyRunning bool) int
- func WatchErrorHandlerFactory(logger *zap.Logger, key string, stopCh chan<- struct{}) func(r *kcache.Reflector, err error)
- func WatcherStop()
- type FilteredWatchDetail
- func (w *FilteredWatchDetail) Drain(ch chan<- interface{}, stopCh chan struct{})
- func (w *FilteredWatchDetail) Get(name string) (runtime.Object, error)
- func (w *FilteredWatchDetail) IsRunning() int
- func (w *FilteredWatchDetail) Key() string
- func (w FilteredWatchDetail) List(selector labels.Selector) ([]runtime.Object, error)
- func (w *FilteredWatchDetail) Namespace() string
- func (w *FilteredWatchDetail) Stop()
- type ResourceCache
- type ResourceLister
- type WatchDetail
- func (w *WatchDetail) Drain(ch chan<- interface{}, stopCh chan struct{})
- func (w *WatchDetail) Get(name string) (runtime.Object, error)
- func (w *WatchDetail) IsRunning() int
- func (w *WatchDetail) Key() string
- func (w *WatchDetail) List(selector labels.Selector) ([]runtime.Object, error)
- func (w *WatchDetail) Namespace() string
- func (w *WatchDetail) Stop()
- type Watcher
- type WatcherOption
- type WrappedWatchDetails
- func (w *WrappedWatchDetails) Drain(ch chan<- interface{}, stopCh chan struct{})
- func (w *WrappedWatchDetails) Get(name string) (runtime.Object, error)
- func (w *WrappedWatchDetails) IsRunning() int
- func (w *WrappedWatchDetails) Key() string
- func (w *WrappedWatchDetails) List(selector labels.Selector) ([]runtime.Object, error)
- func (w *WrappedWatchDetails) Namespace() string
- func (w *WrappedWatchDetails) Stop()
Constants ¶
This section is empty.
Variables ¶
var ( DefaultResyncDuration = time.Second * 180 ResourceWatches = &sync.Map{} // sync.Map{"resourceKey": [sync.Map{"namespace.resourceKey":"watchDetail"}]} )
var Access resource.ResourceAccess
var Namespaces []string
Functions ¶
func WatchCount ¶
WatchCount returns the current count of watchers from the cache. If onlyRunning is true, the count will only include running watchers.
Types ¶
type FilteredWatchDetail ¶
type FilteredWatchDetail struct { Detail *WatchDetail // contains filtered or unexported fields }
FilteredWatcheDetail is a thin wrapped around a WatchDetail used when a NamespaceAll watcher is available it scopes that WatchDetail List and Get calls to a single namespace.
func (*FilteredWatchDetail) Drain ¶
func (w *FilteredWatchDetail) Drain(ch chan<- interface{}, stopCh chan struct{})
func (*FilteredWatchDetail) Get ¶
func (w *FilteredWatchDetail) Get(name string) (runtime.Object, error)
func (*FilteredWatchDetail) IsRunning ¶
func (w *FilteredWatchDetail) IsRunning() int
func (*FilteredWatchDetail) Key ¶
func (w *FilteredWatchDetail) Key() string
func (*FilteredWatchDetail) Namespace ¶
func (w *FilteredWatchDetail) Namespace() string
func (*FilteredWatchDetail) Stop ¶
func (w *FilteredWatchDetail) Stop()
type ResourceCache ¶
type ResourceCache struct {
// contains filtered or unexported fields
}
var Resources *ResourceCache
func NewResourceCache ¶
func NewResourceCache() *ResourceCache
type ResourceLister ¶
type ResourceLister interface { // List will return all objects in this namespace List(selector labels.Selector) (ret []runtime.Object, err error) // Get will attempt to retrieve by namespace and name Get(name string) (runtime.Object, error) // Drain will get events from the queue and send them to the provided channel Drain(ch chan<- interface{}, stopCh chan struct{}) // Stop Stop() // Namespace Namespace() string // Key Key() string // IsRunning returns the count of underlying Watchers that are running for the ResourceLister IsRunning() int }
func WatchForResource ¶
func WatchForResource(r resource.Resource, namespaces ...string) (ResourceLister, error)
WatchForResource returns a WatchDetail for the given Resource.
func WatchList ¶
func WatchList(onlyRunning bool) []ResourceLister
WatchList returns the current list of watchers from the cache. If onlyRunning is true, the list will only include running watchers.
type WatchDetail ¶
type WatchDetail struct { Informer kcache.SharedInformer StopCh chan struct{} Resource resource.Resource Logger *zap.Logger Queue *workqueue.Type // contains filtered or unexported fields }
WatchDetail holds the details of an Informer and Lister for a specific resource. An optionally configured event queue.
func (*WatchDetail) Drain ¶
func (w *WatchDetail) Drain(ch chan<- interface{}, stopCh chan struct{})
Drain will get events off of the WatchDetail.Queue and send them to the provided channel.
func (*WatchDetail) IsRunning ¶
func (w *WatchDetail) IsRunning() int
IsRunning returns true if the Informer loop for the WatchDetail is running.
func (*WatchDetail) Key ¶
func (w *WatchDetail) Key() string
func (*WatchDetail) Namespace ¶
func (w *WatchDetail) Namespace() string
func (*WatchDetail) Stop ¶
func (w *WatchDetail) Stop()
Stop closes the StopCh shutting down the Drain and Informer loops.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher holds referenecs to the Kubernetes types and a logger. Use NewWatcher to create instances of Watcher.
func NewWatcher ¶
func NewWatcher(ctx context.Context, options ...WatcherOption) (*Watcher, error)
NewWatcher creates a Watcher object. This object is used to hold the reference to the Kubernetes types that implement Informers and Listers.
func (*Watcher) Watch ¶
func (w *Watcher) Watch(ctx context.Context, namespace string, res resource.Resource, queueEvents bool) (ResourceLister, error)
Watch creates a new WatchDetail and starts the watch loop for the given Resource If queueEvents is true, all events for the resource will be added to the WatcheDetail.Queue To handle the events use WatchDetail.Drain
type WatcherOption ¶
type WatcherOption func(*Watcher)
func WithDynamicClient ¶
func WithDynamicClient(d dynamic.Interface) WatcherOption
func WithDynamicSharedInformerFactory ¶
func WithDynamicSharedInformerFactory(dsif dynamicinformer.DynamicSharedInformerFactory) WatcherOption
func WithLogger ¶
func WithLogger(logger *zap.Logger) WatcherOption
func WithNamespace ¶
func WithNamespace(namespace string) WatcherOption
type WrappedWatchDetails ¶
type WrappedWatchDetails struct {
Listers []ResourceLister
}
WrappedWatchDetails combines multiple WatchDetail in to a single call to allow for simple multi-namespace List and Get calls. As a result of this, the other ResourceLister calls have been encoded to be multi-value as a comma seprated string. The responsiblilty of parsing these values is the callers.
func (*WrappedWatchDetails) Drain ¶
func (w *WrappedWatchDetails) Drain(ch chan<- interface{}, stopCh chan struct{})
Drain will get events off of the WatchDetail.Queue and send them to the provided channel.
func (*WrappedWatchDetails) Get ¶
func (w *WrappedWatchDetails) Get(name string) (runtime.Object, error)
func (*WrappedWatchDetails) IsRunning ¶
func (w *WrappedWatchDetails) IsRunning() int
func (*WrappedWatchDetails) Key ¶
func (w *WrappedWatchDetails) Key() string
func (*WrappedWatchDetails) Namespace ¶
func (w *WrappedWatchDetails) Namespace() string
func (*WrappedWatchDetails) Stop ¶
func (w *WrappedWatchDetails) Stop()
Stop closes the StopCh shutting down the Drain and Informer loops.