Documentation ¶
Overview ¶
Package watch implements a garbage collector for composed resource watches.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ControllerEngine ¶
type ControllerEngine interface { GetWatches(name string) ([]engine.WatchID, error) StopWatches(ctx context.Context, name string, ws ...engine.WatchID) (int, error) GetClient() client.Client }
A ControllerEngine can get and stop watches for a controller.
type GarbageCollector ¶
type GarbageCollector struct {
// contains filtered or unexported fields
}
A GarbageCollector garbage collects watches for a single composite resource (XR) controller. A watch is eligible for garbage collection when none of the XRs the controller owns resource references its GVK. The garbage collector periodically lists all of the controller's XRs to determine what GVKs they still reference.
func NewGarbageCollector ¶
func NewGarbageCollector(name string, of resource.CompositeKind, ce ControllerEngine, o ...GarbageCollectorOption) *GarbageCollector
NewGarbageCollector creates a new watch garbage collector for a controller.
func (*GarbageCollector) GarbageCollectWatches ¶
func (gc *GarbageCollector) GarbageCollectWatches(ctx context.Context, interval time.Duration)
GarbageCollectWatches runs garbage collection at the specified interval, until the supplied context is cancelled. It stops any watches for resource types that are no longer composed by any composite resource (XR).
func (*GarbageCollector) GarbageCollectWatchesNow ¶
func (gc *GarbageCollector) GarbageCollectWatchesNow(ctx context.Context) error
GarbageCollectWatchesNow stops any watches for resource types that are no longer composed by any composite resource (XR). It's safe to call from multiple goroutines.
type GarbageCollectorOption ¶
type GarbageCollectorOption func(gc *GarbageCollector)
A GarbageCollectorOption configures a GarbageCollector.
func WithLogger ¶
func WithLogger(l logging.Logger) GarbageCollectorOption
WithLogger configures how a GarbageCollector should log.