wrapper

package
v0.36.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AggregatedWatch

func AggregatedWatch(watches ...clients.ResourceWatch) clients.ResourceWatch

func AggregatedWatchFromClients

func AggregatedWatchFromClients(clientOpts ...ClientWatchOpts) clients.ResourceWatch

func NewClusterResourceClient added in v0.11.9

func NewClusterResourceClient(base clients.ResourceClient, cluster string) clients.ResourceClient

Convenience function for wrapping clients only if they point to remote clusters.

func ResourceWatch

func ResourceWatch(rw clients.ResourceWatcher, namespace string, selector map[string]string) clients.ResourceWatch

func SingleResourceWatch

func SingleResourceWatch(rw clients.ResourceWatch, resourceName string) clients.ResourceWatch

Types

type Client

type Client struct {
	clients.ResourceClient
	ProcessResource func(resource resources.Resource)
}

A wrapper.Client wraps a ResourceClient, applying a Processing function to each read and written resource

func NewClusterClient

func NewClusterClient(base clients.ResourceClient, cluster string) *Client

func (*Client) List

func (c *Client) List(namespace string, opts clients.ListOpts) (resources.ResourceList, error)

func (*Client) Read

func (c *Client) Read(namespace, name string, opts clients.ReadOpts) (resources.Resource, error)

func (*Client) Watch

func (c *Client) Watch(namespace string, opts clients.WatchOpts) (<-chan resources.ResourceList, <-chan error, error)

func (*Client) Write

func (c *Client) Write(resource resources.Resource, opts clients.WriteOpts) (resources.Resource, error)

ProcessResource must be called both before and after write. Before so that changes made can be persisted, and after in order to restore changes that might not be persisted by the underlying data store (e.g. ClusterName on Kubernetes).

type ClientWatchOpts

type ClientWatchOpts struct {
	// the watch client to start the watch
	BaseClient clients.ResourceWatcher
	// the namespace to watch
	// will be ignored if the resource
	// is cluster-scoped
	Namespace string

	// if provided, the watch will return lists
	// containing only the single named resource
	// or an empty list
	ResourceName string

	// the label selector to apply to the watch
	Selector map[string]string
}

predefine the options for starting a watch

type WatchAggregator

type WatchAggregator interface {
	clients.ResourceWatcher
	AddWatch(w clients.ResourceWatcher) error
	RemoveWatch(w clients.ResourceWatcher)
}

A wrapper.watchAggregator wraps multiple ResourceWatchers and aggregates a watch on each into a single Watch func

func NewWatchAggregator

func NewWatchAggregator() WatchAggregator

warning to users: The Watch Aggregator sends snapshots composed from multiple source watches If a source watch fails to deliver resource lists and/or is returning errors on the watch channel, resources from that watcher will be removed from the merged resource list.

Syncers should be aware that resources may be missing from snapshots if one of the source watches is not sending snapshots, e.g. on an unreachable remote cluster. We should be careful when invalidating user config or potentially removing resources in these cases

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL