Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClusterReader ¶
type ClusterReader interface { // Get looks up the resource identifier by the key and the GVK in the provided obj reference. If something // goes wrong or the resource doesn't exist, an error is returned. Get(ctx context.Context, key client.ObjectKey, obj *unstructured.Unstructured) error // ListNamespaceScoped looks up the resources of the GVK given in the list and matches the namespace and // selector provided. ListNamespaceScoped(ctx context.Context, list *unstructured.UnstructuredList, namespace string, selector labels.Selector) error // ListClusterScoped looks up the resources of the GVK given in the list and that matches the selector // provided. ListClusterScoped(ctx context.Context, list *unstructured.UnstructuredList, selector labels.Selector) error // Sync is called by the engine before every polling loop, which provides an opportunity for the Reader // to sync caches. Sync(ctx context.Context) error }
ClusterReader is the interface provided to the statusReaders to talk to the cluster. Implementations of this interface allows different caching strategies, for example by pre-fetching resources using LIST calls rather than letting each engine run multiple GET calls against the cluster. This can significantly reduce the number of requests.
type ClusterReaderFactoryFunc ¶
type ClusterReaderFactoryFunc func(reader client.Reader, mapper meta.RESTMapper, identifiers []object.ObjMetadata) (ClusterReader, error)
ClusterReaderFactoryFunc defines the signature for the function the PollerEngine will use to create a new ClusterReader for each statusPollerRunner.
type Options ¶ added in v0.3.0
type Options struct { // PollInterval defines how often the PollerEngine should poll the cluster for the latest // state of the resources. PollInterval time.Duration // ClusterReaderFactoryFunc provides the PollerEngine with a factory function for creating new // StatusReaders. Since these can be stateful, every call to Poll will create a new // ClusterReader. ClusterReaderFactoryFunc ClusterReaderFactoryFunc // StatusReadersFactoryFunc provides the PollerEngine with a factory function for creating new status // clusterReader. Each statusPollerRunner has a separate set of statusReaders, so this will be called // for every call to Poll. StatusReadersFactoryFunc StatusReadersFactoryFunc }
Options contains the different parameters that can be used to adjust the behavior of the PollerEngine. Timeout is not one of the options here as this should be accomplished by setting a timeout on the context: https://golang.org/pkg/context/
type PollerEngine ¶
type PollerEngine struct { Reader client.Reader Mapper meta.RESTMapper }
PollerEngine provides functionality for polling a cluster for status of a set of resources.
func (*PollerEngine) Poll ¶
func (s *PollerEngine) Poll(ctx context.Context, identifiers []object.ObjMetadata, options Options) <-chan event.Event
Poll will create a new statusPollerRunner that will poll all the resources provided and report their status back on the event channel returned. The statusPollerRunner can be cancelled at any time by cancelling the context passed in. The context can be used to stop the polling process by using timeout, deadline or cancellation.
type StatusReader ¶
type StatusReader interface { // ReadStatus will fetch the resource identified by the given identifier // from the cluster and return an ResourceStatus that will contain // information about the latest state of the resource, its computed status // and information about any generated resources. ReadStatus(ctx context.Context, resource object.ObjMetadata) *event.ResourceStatus // ReadStatusForObject is similar to ReadStatus, but instead of looking up the // resource based on an identifier, it will use the passed-in resource. ReadStatusForObject(ctx context.Context, object *unstructured.Unstructured) *event.ResourceStatus }
StatusReader is the main interface for computing status for resources. In this context, a status reader is an object that can fetch a resource of a specific GroupKind from the cluster and compute its status. For resources that can own generated resources, the engine might also have knowledge about how to identify these generated resources and how to compute status for these generated resources.
type StatusReadersFactoryFunc ¶
type StatusReadersFactoryFunc func(reader ClusterReader, mapper meta.RESTMapper) ( statusReaders map[schema.GroupKind]StatusReader, defaultStatusReader StatusReader)
StatusReadersFactoryFunc defines the signature for the function the PollerEngine will use to create the resource statusReaders and the default engine for each statusPollerRunner.