membership

package
v1.26.2-121.3 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package membership is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var ErrIncorrectAddressFormat = errors.New("incorrect address format")

ErrIncorrectAddressFormat is thrown on incorrect address format

View Source
var ErrInsufficientHosts = serviceerror.NewUnavailable("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

View Source
var (
	GRPCResolverModule = fx.Options(
		fx.Provide(newGRPCResolver),
	)
)

Functions

func GRPCResolverURLForTesting added in v1.25.0

func GRPCResolverURLForTesting(monitor Monitor, service primitives.ServiceName) string

This should only be used in unit tests. For normal code, use the *GRPCResolver provided by fx. Monitor may be nil if it's not needed, but then note that GetServiceResolverFromURL will panic.

func NewHostInfoProvider added in v1.16.0

func NewHostInfoProvider(hostInfo HostInfo) *hostInfoProvider

Types

type ChangedEvent

type ChangedEvent struct {
	HostsAdded   []HostInfo
	HostsRemoved []HostInfo
	HostsChanged []HostInfo
}

ChangedEvent describes a change in membership

type GRPCResolver added in v1.18.0

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

GRPCResolver and the resolvers map in grpcBuilder is used to pass a Monitor through a string url.

func (*GRPCResolver) MakeURL added in v1.18.0

func (g *GRPCResolver) MakeURL(service primitives.ServiceName) string

type HostInfo

type HostInfo interface {
	// Identity returns the unique identifier of the host.
	// This may be the same as the address.
	Identity() string
	// GetAddress returns the socket address of the host (i.e. <ip>:<port>).
	// This must be a valid gRPC address.
	GetAddress() string
}

HostInfo represents the host of a Temporal service.

func NewHostInfoFromAddress added in v1.21.0

func NewHostInfoFromAddress(address string) HostInfo

NewHostInfoFromAddress creates a new HostInfo instance from a socket address.

type HostInfoProvider added in v1.16.0

type HostInfoProvider interface {
	HostInfo() HostInfo
}

type MockHostInfoProvider added in v1.16.0

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

MockHostInfoProvider is a mock of HostInfoProvider interface.

func NewMockHostInfoProvider added in v1.16.0

func NewMockHostInfoProvider(ctrl *gomock.Controller) *MockHostInfoProvider

NewMockHostInfoProvider creates a new mock instance.

func (*MockHostInfoProvider) EXPECT added in v1.16.0

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

func (*MockHostInfoProvider) HostInfo added in v1.16.0

func (m *MockHostInfoProvider) HostInfo() HostInfo

HostInfo mocks base method.

type MockHostInfoProviderMockRecorder added in v1.16.0

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

MockHostInfoProviderMockRecorder is the mock recorder for MockHostInfoProvider.

func (*MockHostInfoProviderMockRecorder) HostInfo added in v1.16.0

HostInfo indicates an expected call of HostInfo.

type MockMonitor added in v0.27.0

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

MockMonitor is a mock of Monitor interface.

func NewMockMonitor added in v0.27.0

func NewMockMonitor(ctrl *gomock.Controller) *MockMonitor

NewMockMonitor creates a new mock instance.

func (*MockMonitor) ApproximateMaxPropagationTime added in v1.24.0

func (m *MockMonitor) ApproximateMaxPropagationTime() time.Duration

ApproximateMaxPropagationTime mocks base method.

func (*MockMonitor) EXPECT added in v0.27.0

func (m *MockMonitor) EXPECT() *MockMonitorMockRecorder

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

func (*MockMonitor) EvictSelf added in v0.27.0

func (m *MockMonitor) EvictSelf() error

EvictSelf mocks base method.

func (*MockMonitor) EvictSelfAt added in v1.24.0

func (m *MockMonitor) EvictSelfAt(asOf time.Time) (time.Duration, error)

EvictSelfAt mocks base method.

func (*MockMonitor) GetReachableMembers added in v0.27.0

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

GetReachableMembers mocks base method.

func (*MockMonitor) GetResolver added in v0.27.0

func (m *MockMonitor) GetResolver(service primitives.ServiceName) (ServiceResolver, error)

GetResolver mocks base method.

func (*MockMonitor) SetDraining added in v1.24.0

func (m *MockMonitor) SetDraining(draining bool) error

SetDraining mocks base method.

func (*MockMonitor) Start added in v0.27.0

func (m *MockMonitor) Start()

Start mocks base method.

func (*MockMonitor) WaitUntilInitialized added in v1.20.0

func (m *MockMonitor) WaitUntilInitialized(arg0 context.Context) error

WaitUntilInitialized mocks base method.

type MockMonitorMockRecorder added in v0.27.0

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

MockMonitorMockRecorder is the mock recorder for MockMonitor.

func (*MockMonitorMockRecorder) ApproximateMaxPropagationTime added in v1.24.0

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

ApproximateMaxPropagationTime indicates an expected call of ApproximateMaxPropagationTime.

func (*MockMonitorMockRecorder) EvictSelf added in v0.27.0

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

EvictSelf indicates an expected call of EvictSelf.

func (*MockMonitorMockRecorder) EvictSelfAt added in v1.24.0

func (mr *MockMonitorMockRecorder) EvictSelfAt(asOf any) *gomock.Call

EvictSelfAt indicates an expected call of EvictSelfAt.

func (*MockMonitorMockRecorder) GetReachableMembers added in v0.27.0

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

GetReachableMembers indicates an expected call of GetReachableMembers.

func (*MockMonitorMockRecorder) GetResolver added in v0.27.0

func (mr *MockMonitorMockRecorder) GetResolver(service any) *gomock.Call

GetResolver indicates an expected call of GetResolver.

func (*MockMonitorMockRecorder) SetDraining added in v1.24.0

func (mr *MockMonitorMockRecorder) SetDraining(draining any) *gomock.Call

SetDraining indicates an expected call of SetDraining.

func (*MockMonitorMockRecorder) Start added in v0.27.0

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

Start indicates an expected call of Start.

func (*MockMonitorMockRecorder) WaitUntilInitialized added in v1.20.0

func (mr *MockMonitorMockRecorder) WaitUntilInitialized(arg0 any) *gomock.Call

WaitUntilInitialized indicates an expected call of WaitUntilInitialized.

type MockServiceResolver added in v0.27.0

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

MockServiceResolver is a mock of ServiceResolver interface.

func NewMockServiceResolver added in v0.27.0

func NewMockServiceResolver(ctrl *gomock.Controller) *MockServiceResolver

NewMockServiceResolver creates a new mock instance.

func (*MockServiceResolver) AddListener added in v0.27.0

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

AddListener mocks base method.

func (*MockServiceResolver) AvailableMemberCount added in v1.24.0

func (m *MockServiceResolver) AvailableMemberCount() int

AvailableMemberCount mocks base method.

func (*MockServiceResolver) AvailableMembers added in v1.24.0

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

AvailableMembers mocks base method.

func (*MockServiceResolver) EXPECT added in v0.27.0

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

func (*MockServiceResolver) Lookup added in v0.27.0

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

Lookup mocks base method.

func (*MockServiceResolver) LookupN added in v1.23.0

func (m *MockServiceResolver) LookupN(key string, n int) []HostInfo

LookupN mocks base method.

func (*MockServiceResolver) MemberCount added in v0.27.0

func (m *MockServiceResolver) MemberCount() int

MemberCount mocks base method.

func (*MockServiceResolver) Members added in v0.27.0

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

Members mocks base method.

func (*MockServiceResolver) RemoveListener added in v0.27.0

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

RemoveListener mocks base method.

func (*MockServiceResolver) RequestRefresh added in v1.18.0

func (m *MockServiceResolver) RequestRefresh()

RequestRefresh mocks base method.

type MockServiceResolverMockRecorder added in v0.27.0

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

MockServiceResolverMockRecorder is the mock recorder for MockServiceResolver.

func (*MockServiceResolverMockRecorder) AddListener added in v0.27.0

func (mr *MockServiceResolverMockRecorder) AddListener(name, notifyChannel any) *gomock.Call

AddListener indicates an expected call of AddListener.

func (*MockServiceResolverMockRecorder) AvailableMemberCount added in v1.24.0

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

AvailableMemberCount indicates an expected call of AvailableMemberCount.

func (*MockServiceResolverMockRecorder) AvailableMembers added in v1.24.0

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

AvailableMembers indicates an expected call of AvailableMembers.

func (*MockServiceResolverMockRecorder) Lookup added in v0.27.0

Lookup indicates an expected call of Lookup.

func (*MockServiceResolverMockRecorder) LookupN added in v1.23.0

func (mr *MockServiceResolverMockRecorder) LookupN(key, n any) *gomock.Call

LookupN indicates an expected call of LookupN.

func (*MockServiceResolverMockRecorder) MemberCount added in v0.27.0

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

MemberCount indicates an expected call of MemberCount.

func (*MockServiceResolverMockRecorder) Members added in v0.27.0

Members indicates an expected call of Members.

func (*MockServiceResolverMockRecorder) RemoveListener added in v0.27.0

func (mr *MockServiceResolverMockRecorder) RemoveListener(name any) *gomock.Call

RemoveListener indicates an expected call of RemoveListener.

func (*MockServiceResolverMockRecorder) RequestRefresh added in v1.18.0

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

RequestRefresh indicates an expected call of RequestRefresh.

type Monitor

type Monitor interface {
	// Start causes this service to join the membership ring. Services
	// should not call Start until they are ready to receive requests from
	// other cluster members.
	Start()
	// 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
	// EvictSelfAt is similar to EvictSelf but causes the change to take effect on all
	// hosts at that absolute time (assuming it's in the future). This process should stay
	// alive for at least the returned duration after calling this, so that all membership
	// information can be propagated correctly. The resolution of asOf is whole seconds.
	EvictSelfAt(asOf time.Time) (time.Duration, error)
	// GetResolver returns the service resolver for a service in the cluster.
	GetResolver(service primitives.ServiceName) (ServiceResolver, error)
	// GetReachableMembers returns addresses of all members of the ring.
	GetReachableMembers() ([]string, error)
	// WaitUntilInitialized blocks until initialization is completed and returns the result
	// of initialization. The current implementation does log.Fatal if it can't initialize,
	// so currently this will never return non-nil, except for context cancel/timeout. A
	// future implementation might return more errors.
	WaitUntilInitialized(context.Context) error
	// SetDraining sets the draining state (synchronized through ringpop)
	SetDraining(draining bool) error
	// ApproximateMaxPropagationTime returns an approximate upper bound on propagation time
	// for updates to membership information. This is _not_ a guarantee! This value is only
	// provided to help with startup/shutdown timing as a best-effort.
	ApproximateMaxPropagationTime() time.Duration
}

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

type ServiceResolver

type ServiceResolver interface {
	// Lookup looks up the host that currently owns the resource identified by the given key.
	Lookup(key string) (HostInfo, error)
	// LookupN looks n hosts that owns the resource identified by the given key, if n greater than total number
	// of hosts total number of hosts will be returned
	LookupN(key string, n int) []HostInfo
	// AddListener adds a listener which will get notified on the given channel whenever membership changes.
	AddListener(name string, notifyChannel chan<- *ChangedEvent) error
	// RemoveListener removes a listener for this service.
	RemoveListener(name string) error
	// MemberCount returns the number of known hosts running this service.
	MemberCount() int
	// AvailableMemberCount returns the number of hosts running this service that are accepting requests (not draining).
	AvailableMemberCount() int
	// Members returns all known hosts available for this service.
	Members() []HostInfo
	// AvailableMembers returns all hosts available for this service that are accepting requests (not draining).
	AvailableMembers() []HostInfo
	// RequestRefresh requests that the membership information be refreshed.
	RequestRefresh()
}

ServiceResolver provides membership information for a specific temporal service. It can also be used to determine the placement of resources across hosts.

func GetServiceResolverFromURL added in v1.25.0

func GetServiceResolverFromURL(u *url.URL) (ServiceResolver, error)

Most code should not use this, this is only exposed for code that has to recognize and use a grpc membership url outside of grpc.

Directories

Path Synopsis
Package ringpop provides a service-based membership monitor
Package ringpop provides a service-based membership monitor

Jump to

Keyboard shortcuts

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