watcher

package
v3.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: Apache-2.0 Imports: 14 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregator

type Aggregator struct {
	infra.PluginDeps

	Resync   *resync.Plugin
	Local    *syncbase.Registry
	Watchers []datasync.KeyValProtoWatcher
	// contains filtered or unexported fields
}

Aggregator is an adapter that allows multiple watchers (KeyValProtoWatcher) to be aggregated in one. Watch request is delegated to all of them.

func NewPlugin

func NewPlugin(opts ...Option) *Aggregator

NewPlugin creates a new Plugin with the provides Options

func (*Aggregator) Init

func (p *Aggregator) Init() error

func (*Aggregator) Watch

func (p *Aggregator) Watch(
	resyncName string,
	changeChan chan datasync.ChangeEvent,
	resyncChan chan datasync.ResyncEvent,
	keyPrefixes ...string,
) (datasync.WatchRegistration, error)

Watch subscribes to every transport available within transport aggregator and also subscribes to localclient (local.Registry). The function implements KeyValProtoWatcher.Watch().

type Config added in v3.3.0

type Config struct {
	// ResyncDataSourceOverride overrides default data source (empty in aggregator and later elsewhere
	// set to "datasync") to support certain use cases where data sources must match otherwise resync doesn't
	// affect the same set of data (i.e. using only initfile watcher to fill initial data and agentctl resync
	// to clean them -> agentctl resync works only on 'grpc'-sourced data and default 'datasync'-sourced
	// initfile data couldn't be handled)
	// This is not a full solution covering all combinations of watchers and agentctl resync, but rather
	// a possible fix for some use cases. The full solution should handle multiple resyncs (one per data source)
	// and all its corner cases.
	ResyncDataSourceOverride string `json:"resync-data-source-override"`
}

Config holds the Aggregator configuration.

type Option

type Option func(*Aggregator)

Option is a function that acts on a Plugin to inject Dependencies or configuration

func UseWatchers

func UseWatchers(watchers ...datasync.KeyValProtoWatcher) Option

UseWatchers returns option that sets watchers.

type WatchRegistration

type WatchRegistration struct {
	Registrations []datasync.WatchRegistration
}

WatchRegistration is adapter that allows multiple registrations (WatchRegistration) to be aggregated in one. Close operation is applied collectively to all included registration.

func (*WatchRegistration) Close

func (wa *WatchRegistration) Close() error

Close every registration under the aggregator. This function implements WatchRegistration.Close().

func (*WatchRegistration) Register

func (wa *WatchRegistration) Register(resyncName, keyPrefix string) error

Register new key for all available aggregator objects. Call Register(keyPrefix) on specific registration to add the key from that registration only

func (*WatchRegistration) Unregister

func (wa *WatchRegistration) Unregister(keyPrefix string) error

Unregister closed registration of specific key under all available aggregator objects. Call Unregister(keyPrefix) on specific registration to remove the key from that registration only

Jump to

Keyboard shortcuts

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