observer

package
v0.0.0-...-9b96d08 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultObservationInterval = 10 * time.Second
	DefaultRequestTimeout      = 1 * time.Minute
)

Default values: - best-case scenario (healthy cluster): a request is performed every 10 seconds - worst-case scenario (unhealthy cluster): a request is performed every 70 (60+10) seconds

View Source
const (
	// FinalizerName registered for each elasticsearch resource
	FinalizerName = "finalizer.zookeeper.ghostbaby.io/observer"
)

Variables

View Source
var DefaultSettings = Settings{
	ObservationInterval: DefaultObservationInterval,
	RequestTimeout:      DefaultRequestTimeout,
}

DefaultSettings is an observer's Params with default values

Functions

func WatchClusterHealthChange

func WatchClusterHealthChange(m *Manager) *source.Channel

WatchClusterHealthChange returns a Source fed with generic events targeting clusters whose health has changed between 2 observations. Aimed to be used for triggering a reconciliation.

Types

type Manager

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

Manager for a set of observers

func NewManager

func NewManager(settings Settings) *Manager

NewManager returns a new manager

func (*Manager) AddObservationListener

func (m *Manager) AddObservationListener(listener OnObservation)

AddObservationListener adds the given listener to the list of listeners notified on every observation.

func (*Manager) Finalizer

func (m *Manager) Finalizer(cluster types.NamespacedName) finalizer.Finalizer

Finalizer returns a finalizer to be executed upon deletion of the given cluster, that makes sure the cluster is not observed anymore

func (*Manager) Observe

func (m *Manager) Observe(cluster types.NamespacedName, zkClient zk.BaseClient) *Observer

Observe gets or create a cluster state observer for the given cluster In case something has changed in the given zkClient (eg. different caCert), the observer is recreated accordingly

func (*Manager) ObservedStateResolver

func (m *Manager) ObservedStateResolver(cluster types.NamespacedName, zkClient zk.BaseClient) State

func (*Manager) StopObserving

func (m *Manager) StopObserving(cluster types.NamespacedName)

type Observer

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

func NewObserver

func NewObserver(cluster types.NamespacedName, esClient zk.BaseClient, settings Settings, onObservation OnObservation) *Observer

NewObserver creates and starts an Observer

func (*Observer) LastState

func (o *Observer) LastState() State

LastState returns the last observed state

func (*Observer) Start

func (o *Observer) Start()

Start the observer in a separate goroutine

func (*Observer) Stop

func (o *Observer) Stop()

type OnObservation

type OnObservation func(cluster types.NamespacedName, previousState State, newState State)

OnObservation is a function that gets executed when a new state is observed

type Settings

type Settings struct {
	ObservationInterval time.Duration
	RequestTimeout      time.Duration
}

Settings for the Observer configuration

type State

type State struct {
	ClusterStats *zk.ClusterStats
}

func RetrieveState

func RetrieveState(ctx context.Context, cluster types.NamespacedName, zkClient zk.BaseClient) State

RetrieveState returns the current Zookeeper cluster state

Jump to

Keyboard shortcuts

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