component

package
v0.0.0-...-7b34d14 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component interface {
	// Start blocks until the channel is closed or an error occurs.
	// The component will stop running when the channel is closed.
	Start(<-chan struct{}) error

	// NeedLeaderElection indicates if component should be run only by one instance of Control Plane even with many Control Plane replicas.
	NeedLeaderElection() bool
}

Component defines a process that will be run in the application Component should be designed in such a way that it can be stopped by stop channel and started again (for example when instance is reelected for a leader).

func NewResilientComponent

func NewResilientComponent(log logr.Logger, component Component) Component

type ComponentFunc

type ComponentFunc func(<-chan struct{}) error

func (ComponentFunc) NeedLeaderElection

func (f ComponentFunc) NeedLeaderElection() bool

func (ComponentFunc) Start

func (f ComponentFunc) Start(stop <-chan struct{}) error

type LeaderCallbacks

type LeaderCallbacks struct {
	OnStartedLeading func()
	OnStoppedLeading func()
}

LeaderCallbacks defines callbacks for events from LeaderElector It is guaranteed that each methods will be executed from the same goroutine, so only one method can be run at once.

type LeaderElector

type LeaderElector interface {
	AddCallbacks(LeaderCallbacks)
	// IsLeader should be used for diagnostic reasons (metrics/API info), because there may not be any leader elector for a short period of time.
	// Use Callbacks to write logic to execute when Leader is elected.
	IsLeader() bool

	// Start blocks until the channel is closed or an error occurs.
	Start(stop <-chan struct{})
}

type LeaderInfo

type LeaderInfo interface {
	IsLeader() bool
}

type LeaderInfoComponent

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

func (*LeaderInfoComponent) IsLeader

func (p *LeaderInfoComponent) IsLeader() bool

func (*LeaderInfoComponent) NeedLeaderElection

func (l *LeaderInfoComponent) NeedLeaderElection() bool

func (*LeaderInfoComponent) Start

func (l *LeaderInfoComponent) Start(stop <-chan struct{}) error

type Manager

type Manager interface {

	// Add registers a component, i.e. gRPC Server, HTTP server, reconciliation loop.
	Add(...Component) error

	// Start starts registered components and blocks until the Stop channel is closed.
	// Returns an error if there is an error starting any component.
	Start(<-chan struct{}) error
}

func NewManager

func NewManager(leaderElector LeaderElector) Manager

Jump to

Keyboard shortcuts

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