updater

package
v0.0.0-...-1fc1f69 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package updater provides implements the application of a complete set of or observed changes to cluster data to the Turbine API with a minimum delay between updates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Loop

func Loop(updater Updater, get func() ([]api.Cluster, error))

Loop is a utility function for Rotor plugins that periodically polls for updates. It invokes the get function at the Updater's minimum update interval (since more frequent updates would be ignored). The result of get is passed to Updater.Replace, unless there is an error, in which case the error is logged. Loop installs a signal handler for SIGINT and SIGTERM (viaa SignalNotifier). If it receives either signal, it exits the polling loop after closing the Updater.

func New

func New(
	differ differ.Differ,
	delay time.Duration,
	diffOpts differ.DiffOpts,
	zoneName string,
) *updater

func SignalNotifier

func SignalNotifier() chan os.Signal

SignalNotifier creates a chan os.Signal that will receive the SIGINT and SIGTERM signals if the current process receives them. If Loop is inadequate for your Rotor plugin, this function can be used to provide the same exit-on-signal behavior. See github.com/

func StopLoop

func StopLoop()

StopLoop stops a running Loop invocation by simulating a signal. This function is intended for use in tests only. StopLoop assumes only one event loop is running in a given process, and therefore only the most recently created Loop or SignalNotifier will receive the simulated signal.

Types

type FromFlagOptions

type FromFlagOptions func(*fromFlags) *fromFlags

FromFlagOptions lets you add various options to NewFromFlags

func SkipMinDelay

func SkipMinDelay() FromFlagOptions

SkipMinDelay skips enforcement of a minimum delay

func WithDefaultDelay

func WithDefaultDelay(i uint) FromFlagOptions

WithDefaultDelay allows specification of a flag-configured delay

type FromFlags

type FromFlags interface {
	Validate() error
	Make(service.All, api.Zone) Updater
	MakeStandalone(
		port int,
		proxyName,
		zoneName string,
	) (func(poller.Consumer) Updater, poller.Registrar)
}

FromFlags represents command-line flags specifying configuration of an Updater.

func NewFromFlags

func NewFromFlags(
	flagset tbnflag.FlagSet,
	opts ...FromFlagOptions,
) FromFlags

NewFromFlags installs a FromFlags in the given FlagSet

type MockFromFlags

type MockFromFlags struct {
	// contains filtered or unexported fields
}

MockFromFlags is a mock of FromFlags interface

func NewMockFromFlags

func NewMockFromFlags(ctrl *gomock.Controller) *MockFromFlags

NewMockFromFlags creates a new mock instance

func (*MockFromFlags) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockFromFlags) Make

func (m *MockFromFlags) Make(arg0 service.All, arg1 api.Zone) Updater

Make mocks base method

func (*MockFromFlags) MakeStandalone

func (m *MockFromFlags) MakeStandalone(port int, proxyName, zoneName string) (func(poller.Consumer) Updater, poller.Registrar)

MakeStandalone mocks base method

func (*MockFromFlags) Validate

func (m *MockFromFlags) Validate() error

Validate mocks base method

type MockFromFlagsMockRecorder

type MockFromFlagsMockRecorder struct {
	// contains filtered or unexported fields
}

MockFromFlagsMockRecorder is the mock recorder for MockFromFlags

func (*MockFromFlagsMockRecorder) Make

func (mr *MockFromFlagsMockRecorder) Make(arg0, arg1 interface{}) *gomock.Call

Make indicates an expected call of Make

func (*MockFromFlagsMockRecorder) MakeStandalone

func (mr *MockFromFlagsMockRecorder) MakeStandalone(port, proxyName, zoneName interface{}) *gomock.Call

MakeStandalone indicates an expected call of MakeStandalone

func (*MockFromFlagsMockRecorder) Validate

func (mr *MockFromFlagsMockRecorder) Validate() *gomock.Call

Validate indicates an expected call of Validate

type MockUpdater

type MockUpdater struct {
	// contains filtered or unexported fields
}

MockUpdater is a mock of Updater interface

func NewMockUpdater

func NewMockUpdater(ctrl *gomock.Controller) *MockUpdater

NewMockUpdater creates a new mock instance

func (*MockUpdater) Close

func (m *MockUpdater) Close() error

Close mocks base method

func (*MockUpdater) Delay

func (m *MockUpdater) Delay() time.Duration

Delay mocks base method

func (*MockUpdater) EXPECT

func (m *MockUpdater) EXPECT() *MockUpdaterMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockUpdater) Replace

func (m *MockUpdater) Replace(clusters []api.Cluster)

Replace mocks base method

func (*MockUpdater) ZoneName

func (m *MockUpdater) ZoneName() string

ZoneName mocks base method

type MockUpdaterMockRecorder

type MockUpdaterMockRecorder struct {
	// contains filtered or unexported fields
}

MockUpdaterMockRecorder is the mock recorder for MockUpdater

func (*MockUpdaterMockRecorder) Close

func (mr *MockUpdaterMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close

func (*MockUpdaterMockRecorder) Delay

func (mr *MockUpdaterMockRecorder) Delay() *gomock.Call

Delay indicates an expected call of Delay

func (*MockUpdaterMockRecorder) Replace

func (mr *MockUpdaterMockRecorder) Replace(clusters interface{}) *gomock.Call

Replace indicates an expected call of Replace

func (*MockUpdaterMockRecorder) ZoneName

func (mr *MockUpdaterMockRecorder) ZoneName() *gomock.Call

ZoneName indicates an expected call of ZoneName

type Updater

type Updater interface {
	// Replace discards any unapplied changes (from previous
	// delayed operations).  It schedules changes to remove all
	// existing instances the given clusters and to add all
	// instances in the given clusters. Clusters are created or
	// deleted only if the appropriate flags are set when creating
	// the Updater. If sufficient time has elapsed since the last
	// update, the scheduled update is executed immediately.
	Replace(clusters []api.Cluster)

	// Delay returns the minimum delay between API updates.
	Delay() time.Duration

	// ZoneName returns the name of the zone we're managing updates for.
	ZoneName() string

	// Close stops the Updater and releases its resources.
	Close() error
}

Updater provies a mechanism for updating a set of Clusters within a Zone at specified interval.

Jump to

Keyboard shortcuts

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