membership

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: MIT Imports: 15 Imported by: 19

Documentation

Overview

Package membership is a generated GoMock package.

Index

Constants

View Source
const (
	// RoleKey label is set by every single service as soon as it bootstraps its
	// ringpop instance. The data for this key is the service name
	RoleKey = "serviceName"
)

Variables

View Source
var ErrInsufficientHosts = &shared.InternalServiceError{Message: "Not enough hosts to serve the request"}

ErrInsufficientHosts is thrown when there are not enough hosts to serve the request

View Source
var ErrListenerAlreadyExist = errors.New("Listener already exist for the service")

ErrListenerAlreadyExist is thrown on a duplicate AddListener call from the same listener

View Source
var ErrUnknownService = errors.New("Service not tracked by Monitor")

ErrUnknownService is thrown for a service that is not tracked by this instance

Functions

This section is empty.

Types

type ChangedEvent

type ChangedEvent struct {
	HostsAdded   []*HostInfo
	HostsUpdated []*HostInfo
	HostsRemoved []*HostInfo
}

ChangedEvent describes a change in membership

type HostInfo

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

HostInfo is a type that contains the info about a cadence host

func NewHostInfo

func NewHostInfo(addr string, labels map[string]string) *HostInfo

NewHostInfo creates a new HostInfo instance

func (*HostInfo) GetAddress

func (hi *HostInfo) GetAddress() string

GetAddress returns the ip:port address

func (*HostInfo) Identity

func (hi *HostInfo) Identity() string

Identity implements ringpop's Membership interface

func (*HostInfo) Label

func (hi *HostInfo) Label(key string) (value string, has bool)

Label implements ringpop's Membership interface

func (*HostInfo) SetLabel

func (hi *HostInfo) SetLabel(key string, value string)

SetLabel sets the label.

type MockMonitor added in v0.11.0

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

MockMonitor is a mock of Monitor interface

func NewMockMonitor added in v0.11.0

func NewMockMonitor(ctrl *gomock.Controller) *MockMonitor

NewMockMonitor creates a new mock instance

func (*MockMonitor) AddListener added in v0.11.0

func (m *MockMonitor) AddListener(service, name string, notifyChannel chan<- *ChangedEvent) error

AddListener mocks base method

func (*MockMonitor) EXPECT added in v0.11.0

func (m *MockMonitor) EXPECT() *MockMonitorMockRecorder

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

func (*MockMonitor) EvictSelf added in v0.12.0

func (m *MockMonitor) EvictSelf() error

EvictSelf mocks base method

func (*MockMonitor) GetMemberCount added in v0.12.0

func (m *MockMonitor) GetMemberCount(role string) (int, error)

GetMemberCount mocks base method

func (*MockMonitor) GetReachableMembers added in v0.11.0

func (m *MockMonitor) GetReachableMembers() ([]string, error)

GetReachableMembers mocks base method

func (*MockMonitor) GetResolver added in v0.11.0

func (m *MockMonitor) GetResolver(service string) (ServiceResolver, error)

GetResolver mocks base method

func (*MockMonitor) Lookup added in v0.11.0

func (m *MockMonitor) Lookup(service, key string) (*HostInfo, error)

Lookup mocks base method

func (*MockMonitor) RemoveListener added in v0.11.0

func (m *MockMonitor) RemoveListener(service, name string) error

RemoveListener mocks base method

func (*MockMonitor) Start added in v0.11.0

func (m *MockMonitor) Start()

Start mocks base method

func (*MockMonitor) Stop added in v0.11.0

func (m *MockMonitor) Stop()

Stop mocks base method

func (*MockMonitor) WhoAmI added in v0.11.0

func (m *MockMonitor) WhoAmI() (*HostInfo, error)

WhoAmI mocks base method

type MockMonitorMockRecorder added in v0.11.0

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

MockMonitorMockRecorder is the mock recorder for MockMonitor

func (*MockMonitorMockRecorder) AddListener added in v0.11.0

func (mr *MockMonitorMockRecorder) AddListener(service, name, notifyChannel interface{}) *gomock.Call

AddListener indicates an expected call of AddListener

func (*MockMonitorMockRecorder) EvictSelf added in v0.12.0

func (mr *MockMonitorMockRecorder) EvictSelf() *gomock.Call

EvictSelf indicates an expected call of EvictSelf

func (*MockMonitorMockRecorder) GetMemberCount added in v0.12.0

func (mr *MockMonitorMockRecorder) GetMemberCount(role interface{}) *gomock.Call

GetMemberCount indicates an expected call of GetMemberCount

func (*MockMonitorMockRecorder) GetReachableMembers added in v0.11.0

func (mr *MockMonitorMockRecorder) GetReachableMembers() *gomock.Call

GetReachableMembers indicates an expected call of GetReachableMembers

func (*MockMonitorMockRecorder) GetResolver added in v0.11.0

func (mr *MockMonitorMockRecorder) GetResolver(service interface{}) *gomock.Call

GetResolver indicates an expected call of GetResolver

func (*MockMonitorMockRecorder) Lookup added in v0.11.0

func (mr *MockMonitorMockRecorder) Lookup(service, key interface{}) *gomock.Call

Lookup indicates an expected call of Lookup

func (*MockMonitorMockRecorder) RemoveListener added in v0.11.0

func (mr *MockMonitorMockRecorder) RemoveListener(service, name interface{}) *gomock.Call

RemoveListener indicates an expected call of RemoveListener

func (*MockMonitorMockRecorder) Start added in v0.11.0

func (mr *MockMonitorMockRecorder) Start() *gomock.Call

Start indicates an expected call of Start

func (*MockMonitorMockRecorder) Stop added in v0.11.0

func (mr *MockMonitorMockRecorder) Stop() *gomock.Call

Stop indicates an expected call of Stop

func (*MockMonitorMockRecorder) WhoAmI added in v0.11.0

func (mr *MockMonitorMockRecorder) WhoAmI() *gomock.Call

WhoAmI indicates an expected call of WhoAmI

type MockServiceResolver added in v0.11.0

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

MockServiceResolver is a mock of ServiceResolver interface

func NewMockServiceResolver added in v0.11.0

func NewMockServiceResolver(ctrl *gomock.Controller) *MockServiceResolver

NewMockServiceResolver creates a new mock instance

func (*MockServiceResolver) AddListener added in v0.11.0

func (m *MockServiceResolver) AddListener(name string, notifyChannel chan<- *ChangedEvent) error

AddListener mocks base method

func (*MockServiceResolver) EXPECT added in v0.11.0

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

func (*MockServiceResolver) Lookup added in v0.11.0

func (m *MockServiceResolver) Lookup(key string) (*HostInfo, error)

Lookup mocks base method

func (*MockServiceResolver) MemberCount added in v0.11.0

func (m *MockServiceResolver) MemberCount() int

MemberCount mocks base method

func (*MockServiceResolver) Members added in v0.11.0

func (m *MockServiceResolver) Members() []*HostInfo

Members mocks base method

func (*MockServiceResolver) RemoveListener added in v0.11.0

func (m *MockServiceResolver) RemoveListener(name string) error

RemoveListener mocks base method

type MockServiceResolverMockRecorder added in v0.11.0

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

MockServiceResolverMockRecorder is the mock recorder for MockServiceResolver

func (*MockServiceResolverMockRecorder) AddListener added in v0.11.0

func (mr *MockServiceResolverMockRecorder) AddListener(name, notifyChannel interface{}) *gomock.Call

AddListener indicates an expected call of AddListener

func (*MockServiceResolverMockRecorder) Lookup added in v0.11.0

func (mr *MockServiceResolverMockRecorder) Lookup(key interface{}) *gomock.Call

Lookup indicates an expected call of Lookup

func (*MockServiceResolverMockRecorder) MemberCount added in v0.11.0

func (mr *MockServiceResolverMockRecorder) MemberCount() *gomock.Call

MemberCount indicates an expected call of MemberCount

func (*MockServiceResolverMockRecorder) Members added in v0.11.0

Members indicates an expected call of Members

func (*MockServiceResolverMockRecorder) RemoveListener added in v0.11.0

func (mr *MockServiceResolverMockRecorder) RemoveListener(name interface{}) *gomock.Call

RemoveListener indicates an expected call of RemoveListener

type Monitor

type Monitor interface {
	common.Daemon

	WhoAmI() (*HostInfo, error)
	// EvictSelf evicts this member from the membership ring. After this method is
	// called, other members will discover that this node is no longer part of the
	// ring. This primitive is useful to carry out graceful host shutdown during deployments.
	EvictSelf() error
	Lookup(service string, key string) (*HostInfo, error)
	GetResolver(service string) (ServiceResolver, error)
	// AddListener adds a listener for this service.
	// The listener will get notified on the given
	// channel, whenever there is a membership change.
	// @service: The service to be listened on
	// @name: The name for identifying the listener
	// @notifyChannel: The channel on which the caller receives notifications
	AddListener(service string, name string, notifyChannel chan<- *ChangedEvent) error
	// RemoveListener removes a listener for this service.
	RemoveListener(service string, name string) error
	// GetReachableMembers returns addresses of all members of the ring
	GetReachableMembers() ([]string, error)
	// GetMemberCount returns the number of reachable members
	// currently in this node's membership list for the given role
	GetMemberCount(role string) (int, error)
}

Monitor provides membership information for all cadence services. It can be used to query which member host of a service is responsible for serving a given key.

func NewRingpopMonitor

func NewRingpopMonitor(
	serviceName string,
	services []string,
	rp *RingPop,
	logger log.Logger,
) Monitor

NewRingpopMonitor returns a ringpop-based membership monitor

type RingPop added in v0.11.0

type RingPop struct {
	*ringpop.Ringpop
	// contains filtered or unexported fields
}

RingPop is a simple wrapper

func NewRingPop added in v0.11.0

func NewRingPop(
	ringPop *ringpop.Ringpop,
	bootParams *swim.BootstrapOptions,
	logger log.Logger,
) *RingPop

NewRingPop create a new ring pop wrapper

func (*RingPop) Start added in v0.11.0

func (r *RingPop) Start()

Start start ring pop

func (*RingPop) Stop added in v0.11.0

func (r *RingPop) Stop()

Stop stop ring pop

type ServiceResolver

type ServiceResolver interface {
	Lookup(key string) (*HostInfo, error)
	// AddListener adds a listener which will get notified on the given
	// channel, whenever membership changes.
	// @name: The name for identifying the listener
	// @notifyChannel: The channel on which the caller receives notifications
	AddListener(name string, notifyChannel chan<- *ChangedEvent) error
	// RemoveListener removes a listener for this service.
	RemoveListener(name string) error
	// MemberCount returns host count in hashring for any particular role
	MemberCount() int
	// Members returns all host addresses in hashring for any particular role
	Members() []*HostInfo
}

ServiceResolver provides membership information for a specific cadence service. It can be used to resolve which member host is responsible for serving a given key.

Jump to

Keyboard shortcuts

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