watchmanager

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2019 License: Apache-2.0 Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options interface {
	// Watcher is the etcd watcher
	Watcher() clientv3.Watcher
	// SetWatcher sets the Watcher
	SetWatcher(w clientv3.Watcher) Options

	// UpdateFn is the function called when a notification on a key is received
	UpdateFn() UpdateFn
	// SetUpdateFn sets the UpdateFn
	SetUpdateFn(f UpdateFn) Options

	// TickAndStopFn is the function called periodically to check if a watch should be stopped
	TickAndStopFn() TickAndStopFn
	// SetTickAndStopFn sets the TickAndStopFn
	SetTickAndStopFn(f TickAndStopFn) Options

	// WatchOptions is a set of options for the etcd watch
	WatchOptions() []clientv3.OpOption
	// SetWatchOptions sets the WatchOptions
	SetWatchOptions(opts []clientv3.OpOption) Options

	// WatchChanCheckInterval will be used to periodically check if a watch chan
	// is no longer being subscribed and should be closed
	WatchChanCheckInterval() time.Duration
	// SetWatchChanCheckInterval sets the WatchChanCheckInterval
	SetWatchChanCheckInterval(t time.Duration) Options

	// WatchChanResetInterval is the delay before resetting the etcd watch chan
	WatchChanResetInterval() time.Duration
	// SetWatchChanResetInterval sets the WatchChanResetInterval
	SetWatchChanResetInterval(t time.Duration) Options

	// WatchChanInitTimeout is the timeout for a watchChan initialization
	WatchChanInitTimeout() time.Duration
	// SetWatchChanInitTimeout sets the WatchChanInitTimeout
	SetWatchChanInitTimeout(t time.Duration) Options

	// InstrumentsOptions is the instrument options
	InstrumentsOptions() instrument.Options
	// SetInstrumentsOptions sets the InstrumentsOptions
	SetInstrumentsOptions(iopts instrument.Options) Options

	// Validate validates the options
	Validate() error
}

Options are options for the etcd watch helper

func NewOptions

func NewOptions() Options

NewOptions creates sane options

type TickAndStopFn

type TickAndStopFn func(key string) bool

TickAndStopFn is called every once a while to check and stop the watch if needed

type UpdateFn

type UpdateFn func(key string, events []*clientv3.Event) error

UpdateFn is called when an event on the watch channel happens

type WatchManager

type WatchManager interface {
	// Watch watches the key forever until the CheckAndStopFn returns true
	Watch(key string)
}

WatchManager manages etcd watch on a key

func NewWatchManager

func NewWatchManager(opts Options) (WatchManager, error)

NewWatchManager creates a new watch manager

Jump to

Keyboard shortcuts

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