locker

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package locker is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var ErrCallbackNotFound = errors.New("Lease callback not found")

ErrCallbackNotFound is launched when a user tries to delete a callback that does not exist

View Source
var ErrGetLeaseTimeout = errors.New("Timeout while trying to get lease")

ErrGetLeaseTimeout is launched when a user calls GetLease and we fail to provide one in time

View Source
var (
	// ErrInvalidEtcdState is an error returned by IsMaster when the key supposed to contain the lock does not exist
	ErrInvalidEtcdState = errors.New("Invalid etcd state: key not found")
)

Functions

This section is empty.

Types

type EtcdLeaseManager added in v1.9.0

type EtcdLeaseManager interface {
	Start(ctx context.Context) error
	Stop(ctx context.Context)
	GetLease(ctx context.Context) (clientv3.LeaseID, error)                                    // This will get the current lease or wait for one to be generated
	MarkLeaseAsDirty(ctx context.Context, leaseID clientv3.LeaseID) error                      // This is sent by clients if they think that there might be an issue with the Lease
	SubscribeToLeaseChange(ctx context.Context, callback LeaseChangedCallback) (string, error) // Subscribe to lease changes. This function returns an ID that should be used to unsubscribe.
	UnsubscribeToLeaseChange(ctx context.Context, id string) error                             // Unsubscribe from the lease changes
}

EtcdLeaseManager let you get the current server lease for the server

func NewEtcdLeaseManager added in v1.9.0

func NewEtcdLeaseManager(ctx context.Context, config config.Config, storage models.Storage, etcd *clientv3.Client) EtcdLeaseManager

NewEtcdLeaseManager returns a default manager that implements the EtcdLeaseManager interface

type LeaseChangedCallback added in v1.9.0

type LeaseChangedCallback func(ctx context.Context, oldLeaseID, newLeaseID clientv3.LeaseID)

LeaseChangedCallback is a callback called by the lease manager when the leaseID has changed so that all managers could try to regenerate their keys

type Locker

type Locker interface {
	Refresh(context.Context) error          // Refresh must be called to refresh our TTL or to try to get the lock
	Unlock(context.Context) error           // Unlock remove the lock and mark the lock accessible for re-election
	IsMaster(context.Context) (bool, error) // IsMaster return true if the lock is allocated to our node
	Stop(context.Context) error             // Stop the locker (cleanup)
}

Locker is a structure that let distribute locks accross the entire networks

func NewEtcdLocker

func NewEtcdLocker(config config.Config, etcd *clientv3.Client, leaseManager EtcdLeaseManager, ip models.IP) Locker

NewEtcdLocker return an implemtation of Locker based on the ETCD database

type MockEtcdLeaseManager added in v1.9.0

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

MockEtcdLeaseManager is a mock of EtcdLeaseManager interface

func NewMockEtcdLeaseManager added in v1.9.0

func NewMockEtcdLeaseManager(ctrl *gomock.Controller) *MockEtcdLeaseManager

NewMockEtcdLeaseManager creates a new mock instance

func (*MockEtcdLeaseManager) EXPECT added in v1.9.0

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

func (*MockEtcdLeaseManager) GetLease added in v1.9.0

GetLease mocks base method

func (*MockEtcdLeaseManager) MarkLeaseAsDirty added in v1.9.0

func (m *MockEtcdLeaseManager) MarkLeaseAsDirty(arg0 context.Context, arg1 clientv3.LeaseID) error

MarkLeaseAsDirty mocks base method

func (*MockEtcdLeaseManager) Start added in v1.9.0

func (m *MockEtcdLeaseManager) Start(arg0 context.Context) error

Start mocks base method

func (*MockEtcdLeaseManager) Stop added in v1.9.0

func (m *MockEtcdLeaseManager) Stop(arg0 context.Context)

Stop mocks base method

func (*MockEtcdLeaseManager) SubscribeToLeaseChange added in v1.9.0

func (m *MockEtcdLeaseManager) SubscribeToLeaseChange(arg0 context.Context, arg1 LeaseChangedCallback) (string, error)

SubscribeToLeaseChange mocks base method

func (*MockEtcdLeaseManager) UnsubscribeToLeaseChange added in v1.9.0

func (m *MockEtcdLeaseManager) UnsubscribeToLeaseChange(arg0 context.Context, arg1 string) error

UnsubscribeToLeaseChange mocks base method

type MockEtcdLeaseManagerMockRecorder added in v1.9.0

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

MockEtcdLeaseManagerMockRecorder is the mock recorder for MockEtcdLeaseManager

func (*MockEtcdLeaseManagerMockRecorder) GetLease added in v1.9.0

func (mr *MockEtcdLeaseManagerMockRecorder) GetLease(arg0 interface{}) *gomock.Call

GetLease indicates an expected call of GetLease

func (*MockEtcdLeaseManagerMockRecorder) MarkLeaseAsDirty added in v1.9.0

func (mr *MockEtcdLeaseManagerMockRecorder) MarkLeaseAsDirty(arg0, arg1 interface{}) *gomock.Call

MarkLeaseAsDirty indicates an expected call of MarkLeaseAsDirty

func (*MockEtcdLeaseManagerMockRecorder) Start added in v1.9.0

func (mr *MockEtcdLeaseManagerMockRecorder) Start(arg0 interface{}) *gomock.Call

Start indicates an expected call of Start

func (*MockEtcdLeaseManagerMockRecorder) Stop added in v1.9.0

func (mr *MockEtcdLeaseManagerMockRecorder) Stop(arg0 interface{}) *gomock.Call

Stop indicates an expected call of Stop

func (*MockEtcdLeaseManagerMockRecorder) SubscribeToLeaseChange added in v1.9.0

func (mr *MockEtcdLeaseManagerMockRecorder) SubscribeToLeaseChange(arg0, arg1 interface{}) *gomock.Call

SubscribeToLeaseChange indicates an expected call of SubscribeToLeaseChange

func (*MockEtcdLeaseManagerMockRecorder) UnsubscribeToLeaseChange added in v1.9.0

func (mr *MockEtcdLeaseManagerMockRecorder) UnsubscribeToLeaseChange(arg0, arg1 interface{}) *gomock.Call

UnsubscribeToLeaseChange indicates an expected call of UnsubscribeToLeaseChange

Directories

Path Synopsis
Package lockermock is a generated GoMock package.
Package lockermock is a generated GoMock package.

Jump to

Keyboard shortcuts

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