locker

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package locker is a generated GoMock package.

Index

Constants

View Source
const DataVersion = 1

Variables

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")

	// ErrNotMaster is an error returned by Unlock when we try to unlock an IP that belongs to someone else
	ErrNotMaster = errors.New("current host is not master of this lock")
)
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

Functions

This section is empty.

Types

type EtcdLeaseManager

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

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

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

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

MockEtcdLeaseManager is a mock of EtcdLeaseManager interface.

func NewMockEtcdLeaseManager

func NewMockEtcdLeaseManager(ctrl *gomock.Controller) *MockEtcdLeaseManager

NewMockEtcdLeaseManager creates a new mock instance.

func (*MockEtcdLeaseManager) EXPECT

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

func (*MockEtcdLeaseManager) GetLease

GetLease mocks base method.

func (*MockEtcdLeaseManager) MarkLeaseAsDirty

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

MarkLeaseAsDirty mocks base method.

func (*MockEtcdLeaseManager) Start

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

Start mocks base method.

func (*MockEtcdLeaseManager) Stop

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

Stop mocks base method.

func (*MockEtcdLeaseManager) SubscribeToLeaseChange

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

SubscribeToLeaseChange mocks base method.

func (*MockEtcdLeaseManager) UnsubscribeToLeaseChange

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

UnsubscribeToLeaseChange mocks base method.

type MockEtcdLeaseManagerMockRecorder

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

MockEtcdLeaseManagerMockRecorder is the mock recorder for MockEtcdLeaseManager.

func (*MockEtcdLeaseManagerMockRecorder) GetLease

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

GetLease indicates an expected call of GetLease.

func (*MockEtcdLeaseManagerMockRecorder) MarkLeaseAsDirty

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

MarkLeaseAsDirty indicates an expected call of MarkLeaseAsDirty.

func (*MockEtcdLeaseManagerMockRecorder) Start

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

Start indicates an expected call of Start.

func (*MockEtcdLeaseManagerMockRecorder) Stop

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

Stop indicates an expected call of Stop.

func (*MockEtcdLeaseManagerMockRecorder) SubscribeToLeaseChange

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

SubscribeToLeaseChange indicates an expected call of SubscribeToLeaseChange.

func (*MockEtcdLeaseManagerMockRecorder) UnsubscribeToLeaseChange

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