uniqueness

package
v0.0.0-...-19bd712 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LeaseDuration is the duration that non-leader candidates will
	// wait to force acquire leadership. This is measured against time of
	// last observed ack.
	//
	LeaseDuration = 5 * time.Second
	// RenewDeadline is the duration that the acting manager will retry
	// refreshing leadership before giving up.
	//
	RenewDeadline = 3 * time.Second

	// RetryPeriod is the duration the LeaderElector clients should wait
	// between tries of actions.
	//
	RetryPeriod = 2 * time.Second

	// FirstLeaderDeadline is the duration to wait for the leader to acquire the lease for the first time.
	// Known issue: the lease is not released when we delete an agent deployment,
	// it's causing the new agents to think that the old agent still hold the lease,
	// therefore, we wait for at least a LeaseDuration + few seconds.
	FirstLeaderDeadline = LeaseDuration + 5*time.Second

	PodNameEnvar = "POD_NAME"

	LeaderLeaseName = "cloudbeat-cluster-leader"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultUniqueManager

type DefaultUniqueManager struct{}

DefaultUniqueManager A dummy leader-election manager to implement the UniquenessManager interface. Use to keep the leaderelection code clean and without a non k8s logic.

func (*DefaultUniqueManager) IsLeader

func (d *DefaultUniqueManager) IsLeader() bool

func (*DefaultUniqueManager) Run

func (*DefaultUniqueManager) Stop

func (d *DefaultUniqueManager) Stop()

type LeaderelectionManager

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

func (*LeaderelectionManager) IsLeader

func (m *LeaderelectionManager) IsLeader() bool

func (*LeaderelectionManager) Run

Run leader election is blocking until a FirstLeaderDeadline timeout has reached.

func (*LeaderelectionManager) Stop

func (m *LeaderelectionManager) Stop()

type Manager

type Manager interface {
	IsLeader() bool
	Run(ctx context.Context) error
	Stop()
}

func NewLeaderElector

func NewLeaderElector(log *logp.Logger, client k8s.Interface) Manager

type MockManager

type MockManager struct {
	mock.Mock
}

MockManager is an autogenerated mock type for the Manager type

func NewMockManager

func NewMockManager(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockManager

NewMockManager creates a new instance of MockManager. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockManager) EXPECT

func (_m *MockManager) EXPECT() *MockManager_Expecter

func (*MockManager) IsLeader

func (_m *MockManager) IsLeader() bool

IsLeader provides a mock function with given fields:

func (*MockManager) Run

func (_m *MockManager) Run(ctx context.Context) error

Run provides a mock function with given fields: ctx

func (*MockManager) Stop

func (_m *MockManager) Stop()

Stop provides a mock function with given fields:

type MockManager_Expecter

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

func (*MockManager_Expecter) IsLeader

IsLeader is a helper method to define mock.On call

func (*MockManager_Expecter) Run

func (_e *MockManager_Expecter) Run(ctx interface{}) *MockManager_Run_Call

Run is a helper method to define mock.On call

  • ctx context.Context

func (*MockManager_Expecter) Stop

Stop is a helper method to define mock.On call

type MockManager_IsLeader_Call

type MockManager_IsLeader_Call struct {
	*mock.Call
}

MockManager_IsLeader_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsLeader'

func (*MockManager_IsLeader_Call) Return

func (*MockManager_IsLeader_Call) Run

func (*MockManager_IsLeader_Call) RunAndReturn

func (_c *MockManager_IsLeader_Call) RunAndReturn(run func() bool) *MockManager_IsLeader_Call

type MockManager_Run_Call

type MockManager_Run_Call struct {
	*mock.Call
}

MockManager_Run_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Run'

func (*MockManager_Run_Call) Return

func (*MockManager_Run_Call) Run

func (_c *MockManager_Run_Call) Run(run func(ctx context.Context)) *MockManager_Run_Call

func (*MockManager_Run_Call) RunAndReturn

func (_c *MockManager_Run_Call) RunAndReturn(run func(context.Context) error) *MockManager_Run_Call

type MockManager_Stop_Call

type MockManager_Stop_Call struct {
	*mock.Call
}

MockManager_Stop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Stop'

func (*MockManager_Stop_Call) Return

func (*MockManager_Stop_Call) Run

func (_c *MockManager_Stop_Call) Run(run func()) *MockManager_Stop_Call

func (*MockManager_Stop_Call) RunAndReturn

func (_c *MockManager_Stop_Call) RunAndReturn(run func()) *MockManager_Stop_Call

Jump to

Keyboard shortcuts

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