watcher

package
v3.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: Apache-2.0 Imports: 10 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 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