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 ¶
- func Loop(updater Updater, get func() ([]api.Cluster, error))
- func New(differ differ.Differ, delay time.Duration, diffOpts differ.DiffOpts, ...) *updater
- func SignalNotifier() chan os.Signal
- func StopLoop()
- type FromFlagOptions
- type FromFlags
- type MockFromFlags
- type MockFromFlagsMockRecorder
- type MockUpdater
- type MockUpdaterMockRecorder
- type Updater
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Loop ¶
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 SignalNotifier ¶
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 ¶
func (m *MockFromFlags) EXPECT() *MockFromFlagsMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
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) 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
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.