Documentation ¶
Index ¶
- Constants
- func EnumerateAddresses(host string, portRange pubcluster.PortRange) []pubcluster.Address
- func LargerGroupMajorMinorVersion(members []pubcluster.MemberInfo) (uint16, error)
- func NewDefaultAddressTranslator() *defaultAddressTranslator
- func NewDefaultPublicAddressTranslator() *defaultPublicAddressTranslator
- func ParseAddress(addr string) (pubcluster.Address, error)
- type AddrSet
- type AddressProvider
- type AddressTranslator
- type CandidateCluster
- type ClusterState
- type ClusterStateChangedEvent
- type ConnectedHandler
- type Connection
- type ConnectionBoundInvocation
- type ConnectionEventHandler
- type ConnectionInvocationFactory
- func (f *ConnectionInvocationFactory) NewConnectionBoundInvocation(message *proto.ClientMessage, conn *Connection, ...) *ConnectionBoundInvocation
- func (f *ConnectionInvocationFactory) NewInvocationOnPartitionOwner(message *proto.ClientMessage, partitionID int32, start time.Time) *invocation.Impl
- func (f *ConnectionInvocationFactory) NewInvocationOnRandomTarget(message *proto.ClientMessage, handler proto.ClientMessageHandler, ...) *invocation.Impl
- func (f *ConnectionInvocationFactory) NewInvocationOnTarget(message *proto.ClientMessage, addr pubcluster.Address, start time.Time) *invocation.Impl
- func (f *ConnectionInvocationFactory) NewMemberBoundInvocation(message *proto.ClientMessage, member *pubcluster.MemberInfo, start time.Time) *MemberBoundInvocation
- type ConnectionInvocationHandler
- type ConnectionInvocationHandlerCreationBundle
- type ConnectionListenerBinder
- type ConnectionManager
- func (m *ConnectionManager) ActiveConnections() []*Connection
- func (m *ConnectionManager) ClusterID() types.UUID
- func (m *ConnectionManager) GetConnectionForAddress(addr pubcluster.Address) *Connection
- func (m *ConnectionManager) GetConnectionForPartition(partitionID int32) *Connection
- func (m *ConnectionManager) GetConnectionForUUID(uuid types.UUID) *Connection
- func (m *ConnectionManager) NextConnectionID() int64
- func (m *ConnectionManager) RandomConnection() *Connection
- func (m *ConnectionManager) SQLConnection() *Connection
- func (m *ConnectionManager) SetInvocationService(s *invocation.Service)
- func (m *ConnectionManager) Start(ctx context.Context) error
- func (m *ConnectionManager) Stop()
- type ConnectionManagerCreationBundle
- type ConnectionState
- type ConnectionStateChangedEvent
- type CreationBundle
- type DefaultAddressProvider
- type FailoverService
- type HeartbeatService
- type Listener
- type MemberBoundInvocation
- type MembersState
- type MembersStateChangedEvent
- type PartitionService
- func (s *PartitionService) GetPartitionID(keyData iserialization.Data) (int32, error)
- func (s *PartitionService) GetPartitionOwner(partitionId int32) (types.UUID, bool)
- func (s *PartitionService) PartitionCount() int32
- func (s *PartitionService) Reset()
- func (s *PartitionService) Update(connID int64, partitions []proto.Pair, version int32)
- type PartitionServiceCreationBundle
- type ResponseHandler
- type Service
- func (s *Service) GetMemberByUUID(uuid types.UUID) *pubcluster.MemberInfo
- func (s *Service) OrderedMembers() []pubcluster.MemberInfo
- func (s *Service) RefreshedSeedAddrs(clusterCtx *CandidateCluster) ([]pubcluster.Address, error)
- func (s *Service) Reset()
- func (s *Service) SQLMember() *pubcluster.MemberInfo
- func (s *Service) SetInvocationService(invService *invocation.Service)
- func (s *Service) TranslateMember(ctx context.Context, m *pubcluster.MemberInfo) (pubcluster.Address, error)
- type ViewListenerService
Constants ¶
const ( // EventConnection is dispatched when a connection to a member is opened/closed. EventConnection = "internal.cluster.connection" // EventMembers is dispatched when cluster service finds out new members are added to the cluster // or when members are removed from cluster EventMembers = "internal.cluster.members" // EventCluster is dispatched after the very first connection to the cluster or the first connection after client disconnected. //and dispatched when all connections to the cluster are closed. EventCluster = "internal.cluster.cluster" )
Variables ¶
This section is empty.
Functions ¶
func EnumerateAddresses ¶ added in v1.1.1
func EnumerateAddresses(host string, portRange pubcluster.PortRange) []pubcluster.Address
func LargerGroupMajorMinorVersion ¶ added in v1.2.0
func LargerGroupMajorMinorVersion(members []pubcluster.MemberInfo) (uint16, error)
LargerGroupMajorMinorVersion finds the version of the most numerous member group by version.
func NewDefaultAddressTranslator ¶
func NewDefaultAddressTranslator() *defaultAddressTranslator
func NewDefaultPublicAddressTranslator ¶
func NewDefaultPublicAddressTranslator() *defaultPublicAddressTranslator
func ParseAddress ¶
func ParseAddress(addr string) (pubcluster.Address, error)
Types ¶
type AddrSet ¶
type AddrSet struct {
// contains filtered or unexported fields
}
func NewAddrSet ¶
func NewAddrSet() AddrSet
func (AddrSet) AddAddr ¶
func (a AddrSet) AddAddr(addr pubcluster.Address)
func (AddrSet) AddAddrs ¶
func (a AddrSet) AddAddrs(addrs []pubcluster.Address)
func (AddrSet) Addrs ¶
func (a AddrSet) Addrs() []pubcluster.Address
type AddressProvider ¶
type AddressProvider interface {
Addresses() ([]pubcluster.Address, error)
}
type AddressTranslator ¶
type AddressTranslator interface { // TranslateMember translates the given member's address to another address TranslateMember(ctx context.Context, member *pubcluster.MemberInfo) (addr pubcluster.Address, err error) }
AddressTranslator is used to resolve private ip address of cloud services.
type CandidateCluster ¶ added in v1.1.0
type CandidateCluster struct { AddressProvider AddressProvider AddressTranslator AddressTranslator Credentials security.Credentials ConnectionStrategy *pubcluster.ConnectionStrategyConfig NetworkCfg *pubcluster.NetworkConfig ClusterName string }
type ClusterState ¶ added in v1.1.1
type ClusterState int
const ( ClusterStateConnected ClusterState = iota ClusterStateDisconnected )
type ClusterStateChangedEvent ¶ added in v1.1.1
type ClusterStateChangedEvent struct { Addr pubcluster.Address State ClusterState }
func NewConnected ¶
func NewConnected(addr pubcluster.Address) *ClusterStateChangedEvent
func NewDisconnected ¶
func NewDisconnected() *ClusterStateChangedEvent
func (*ClusterStateChangedEvent) EventName ¶ added in v1.1.1
func (e *ClusterStateChangedEvent) EventName() string
type ConnectedHandler ¶
type ConnectedHandler func(event *ClusterStateChangedEvent)
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func FilterConns ¶ added in v1.1.1
func FilterConns(conns []*Connection, ok func(conn *Connection) bool) []*Connection
FilterConns removes connections which do not conform to the given criteria. Moodifies conns slice. The order of connections in conns may change.
func (*Connection) ConnectionID ¶
func (c *Connection) ConnectionID() int64
func (*Connection) Endpoint ¶
func (c *Connection) Endpoint() pubcluster.Address
func (*Connection) LocalAddr ¶
func (c *Connection) LocalAddr() string
func (*Connection) MemberUUID ¶ added in v1.2.0
func (c *Connection) MemberUUID() types.UUID
func (*Connection) SetEndpoint ¶ added in v1.1.1
func (c *Connection) SetEndpoint(addr pubcluster.Address)
func (*Connection) String ¶
func (c *Connection) String() string
type ConnectionBoundInvocation ¶
type ConnectionBoundInvocation struct { *invocation.Impl // contains filtered or unexported fields }
func (*ConnectionBoundInvocation) CanRetry ¶
func (i *ConnectionBoundInvocation) CanRetry(err error) bool
func (*ConnectionBoundInvocation) Connection ¶
func (i *ConnectionBoundInvocation) Connection() *Connection
func (*ConnectionBoundInvocation) SetEventHandler ¶
func (i *ConnectionBoundInvocation) SetEventHandler(handler proto.ClientMessageHandler)
type ConnectionEventHandler ¶ added in v1.1.1
type ConnectionEventHandler func(event *ConnectionStateChangedEvent)
type ConnectionInvocationFactory ¶
type ConnectionInvocationFactory struct {
// contains filtered or unexported fields
}
func NewConnectionInvocationFactory ¶
func NewConnectionInvocationFactory(config *pubcluster.Config) *ConnectionInvocationFactory
func (*ConnectionInvocationFactory) NewConnectionBoundInvocation ¶
func (f *ConnectionInvocationFactory) NewConnectionBoundInvocation(message *proto.ClientMessage, conn *Connection, handler proto.ClientMessageHandler, start time.Time) *ConnectionBoundInvocation
func (*ConnectionInvocationFactory) NewInvocationOnPartitionOwner ¶
func (f *ConnectionInvocationFactory) NewInvocationOnPartitionOwner(message *proto.ClientMessage, partitionID int32, start time.Time) *invocation.Impl
func (*ConnectionInvocationFactory) NewInvocationOnRandomTarget ¶
func (f *ConnectionInvocationFactory) NewInvocationOnRandomTarget(message *proto.ClientMessage, handler proto.ClientMessageHandler, start time.Time) *invocation.Impl
func (*ConnectionInvocationFactory) NewInvocationOnTarget ¶
func (f *ConnectionInvocationFactory) NewInvocationOnTarget(message *proto.ClientMessage, addr pubcluster.Address, start time.Time) *invocation.Impl
func (*ConnectionInvocationFactory) NewMemberBoundInvocation ¶
func (f *ConnectionInvocationFactory) NewMemberBoundInvocation(message *proto.ClientMessage, member *pubcluster.MemberInfo, start time.Time) *MemberBoundInvocation
type ConnectionInvocationHandler ¶
type ConnectionInvocationHandler struct {
// contains filtered or unexported fields
}
func NewConnectionInvocationHandler ¶
func NewConnectionInvocationHandler(bundle ConnectionInvocationHandlerCreationBundle) *ConnectionInvocationHandler
func (*ConnectionInvocationHandler) Invoke ¶
func (h *ConnectionInvocationHandler) Invoke(inv invocation.Invocation) (int64, error)
type ConnectionInvocationHandlerCreationBundle ¶
type ConnectionInvocationHandlerCreationBundle struct { ConnectionManager *ConnectionManager ClusterService *Service Logger logger.LogAdaptor Config *pubcluster.Config }
func (ConnectionInvocationHandlerCreationBundle) Check ¶
func (b ConnectionInvocationHandlerCreationBundle) Check()
type ConnectionListenerBinder ¶
type ConnectionListenerBinder struct {
// contains filtered or unexported fields
}
func NewConnectionListenerBinder ¶
func NewConnectionListenerBinder( connManager *ConnectionManager, invocationService *invocation.Service, invocationFactory *ConnectionInvocationFactory, eventDispatcher *event.DispatchService, logger logger.LogAdaptor, smart bool) *ConnectionListenerBinder
func (*ConnectionListenerBinder) Add ¶
func (b *ConnectionListenerBinder) Add(ctx context.Context, id types.UUID, add *proto.ClientMessage, remove *proto.ClientMessage, handler proto.ClientMessageHandler) error
type ConnectionManager ¶
type ConnectionManager struct {
// contains filtered or unexported fields
}
func NewConnectionManager ¶
func NewConnectionManager(bundle ConnectionManagerCreationBundle) *ConnectionManager
func (*ConnectionManager) ActiveConnections ¶
func (m *ConnectionManager) ActiveConnections() []*Connection
func (*ConnectionManager) ClusterID ¶ added in v1.2.0
func (m *ConnectionManager) ClusterID() types.UUID
ClusterID returns the id of the connected cluster at that moment. If the client is not connected to any cluster yet, it returns an empty UUID.
func (*ConnectionManager) GetConnectionForAddress ¶
func (m *ConnectionManager) GetConnectionForAddress(addr pubcluster.Address) *Connection
func (*ConnectionManager) GetConnectionForPartition ¶
func (m *ConnectionManager) GetConnectionForPartition(partitionID int32) *Connection
func (*ConnectionManager) GetConnectionForUUID ¶ added in v1.1.1
func (m *ConnectionManager) GetConnectionForUUID(uuid types.UUID) *Connection
func (*ConnectionManager) NextConnectionID ¶
func (m *ConnectionManager) NextConnectionID() int64
func (*ConnectionManager) RandomConnection ¶
func (m *ConnectionManager) RandomConnection() *Connection
func (*ConnectionManager) SQLConnection ¶ added in v1.2.0
func (m *ConnectionManager) SQLConnection() *Connection
func (*ConnectionManager) SetInvocationService ¶ added in v1.1.1
func (m *ConnectionManager) SetInvocationService(s *invocation.Service)
SetInvocationService sets the invocation service for the connection manager. This method should be called before Start.
func (*ConnectionManager) Stop ¶
func (m *ConnectionManager) Stop()
type ConnectionManagerCreationBundle ¶
type ConnectionManagerCreationBundle struct { Logger logger.LogAdaptor PartitionService *PartitionService InvocationFactory *ConnectionInvocationFactory ClusterConfig *pubcluster.Config ClusterService *Service SerializationService *iserialization.Service EventDispatcher *event.DispatchService FailoverService *FailoverService FailoverConfig *pubcluster.FailoverConfig IsClientShutdown func() bool ClientName string Labels []string }
func (ConnectionManagerCreationBundle) Check ¶
func (b ConnectionManagerCreationBundle) Check()
type ConnectionState ¶ added in v1.1.1
type ConnectionState int
const ( ConnectionStateOpened ConnectionState = iota ConnectionStateClosed )
type ConnectionStateChangedEvent ¶ added in v1.1.1
type ConnectionStateChangedEvent struct { Conn *Connection Err error // contains filtered or unexported fields }
func NewConnectionClosed ¶
func NewConnectionClosed(conn *Connection, err error) *ConnectionStateChangedEvent
func NewConnectionOpened ¶
func NewConnectionOpened(conn *Connection) *ConnectionStateChangedEvent
func (ConnectionStateChangedEvent) EventName ¶ added in v1.1.1
func (c ConnectionStateChangedEvent) EventName() string
type CreationBundle ¶
type CreationBundle struct { Logger logger.LogAdaptor InvocationFactory *ConnectionInvocationFactory EventDispatcher *event.DispatchService PartitionService *PartitionService FailoverService *FailoverService Config *pubcluster.Config }
func (CreationBundle) Check ¶
func (b CreationBundle) Check()
type DefaultAddressProvider ¶
type DefaultAddressProvider struct {
// contains filtered or unexported fields
}
func NewDefaultAddressProvider ¶
func NewDefaultAddressProvider(networkConfig *pubcluster.NetworkConfig) *DefaultAddressProvider
func (DefaultAddressProvider) Addresses ¶
func (p DefaultAddressProvider) Addresses() ([]pubcluster.Address, error)
type FailoverService ¶ added in v1.1.0
type FailoverService struct {
// contains filtered or unexported fields
}
FailoverService is responsible for cluster failover state and attempts management.
func NewFailoverService ¶ added in v1.1.0
func NewFailoverService(logger logger.LogAdaptor, maxTries int, rootConfig pubcluster.Config, foConfigs []pubcluster.Config, addrFn addrFun) *FailoverService
func (*FailoverService) Current ¶ added in v1.1.0
func (s *FailoverService) Current() *CandidateCluster
func (*FailoverService) Next ¶ added in v1.1.0
func (s *FailoverService) Next()
type HeartbeatService ¶ added in v1.1.1
type HeartbeatService struct {
// contains filtered or unexported fields
}
func NewHeartbeatService ¶ added in v1.1.1
func NewHeartbeatService(cm *ConnectionManager, f *ConnectionInvocationFactory, invService *invocation.Service, logger logger.LogAdaptor, interval, timeout time.Duration) *HeartbeatService
func (*HeartbeatService) Start ¶ added in v1.1.1
func (hs *HeartbeatService) Start()
func (*HeartbeatService) Stop ¶ added in v1.1.1
func (hs *HeartbeatService) Stop()
type Listener ¶
type Listener interface { ConnectionOpened(connection *Connection) ConnectionClosed(connection *Connection, err error) }
type MemberBoundInvocation ¶
type MemberBoundInvocation struct { *invocation.Impl // contains filtered or unexported fields }
func NewMemberBoundInvocation ¶
func NewMemberBoundInvocation(msg *proto.ClientMessage, member *pubcluster.MemberInfo, deadline time.Time, redoOperation bool) *MemberBoundInvocation
func (*MemberBoundInvocation) CanRetry ¶
func (i *MemberBoundInvocation) CanRetry(err error) bool
type MembersState ¶ added in v1.1.1
type MembersState int
const ( MembersStateAdded MembersState = iota MembersStateRemoved )
type MembersStateChangedEvent ¶ added in v1.1.1
type MembersStateChangedEvent struct { Members []pubcluster.MemberInfo State MembersState }
func NewMemberRemoved ¶
func NewMemberRemoved(members []pubcluster.MemberInfo) *MembersStateChangedEvent
func NewMembersAdded ¶
func NewMembersAdded(members []pubcluster.MemberInfo) *MembersStateChangedEvent
func (MembersStateChangedEvent) EventName ¶ added in v1.1.1
func (m MembersStateChangedEvent) EventName() string
type PartitionService ¶
type PartitionService struct {
// contains filtered or unexported fields
}
func NewPartitionService ¶
func NewPartitionService(bundle PartitionServiceCreationBundle) *PartitionService
func (*PartitionService) GetPartitionID ¶
func (s *PartitionService) GetPartitionID(keyData iserialization.Data) (int32, error)
func (*PartitionService) GetPartitionOwner ¶
func (s *PartitionService) GetPartitionOwner(partitionId int32) (types.UUID, bool)
func (*PartitionService) PartitionCount ¶
func (s *PartitionService) PartitionCount() int32
func (*PartitionService) Reset ¶ added in v1.1.0
func (s *PartitionService) Reset()
type PartitionServiceCreationBundle ¶
type PartitionServiceCreationBundle struct { EventDispatcher *event.DispatchService Logger logger.LogAdaptor }
func (PartitionServiceCreationBundle) Check ¶
func (b PartitionServiceCreationBundle) Check()
type ResponseHandler ¶
type ResponseHandler func(msg *proto.ClientMessage)
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(bundle CreationBundle) *Service
func (*Service) GetMemberByUUID ¶
func (s *Service) GetMemberByUUID(uuid types.UUID) *pubcluster.MemberInfo
func (*Service) OrderedMembers ¶ added in v1.1.1
func (s *Service) OrderedMembers() []pubcluster.MemberInfo
func (*Service) RefreshedSeedAddrs ¶
func (s *Service) RefreshedSeedAddrs(clusterCtx *CandidateCluster) ([]pubcluster.Address, error)
func (*Service) SQLMember ¶ added in v1.2.0
func (s *Service) SQLMember() *pubcluster.MemberInfo
func (*Service) SetInvocationService ¶ added in v1.1.1
func (s *Service) SetInvocationService(invService *invocation.Service)
SetInvocationService sets the invocation service for the cluster service.
func (*Service) TranslateMember ¶ added in v1.1.1
func (s *Service) TranslateMember(ctx context.Context, m *pubcluster.MemberInfo) (pubcluster.Address, error)
type ViewListenerService ¶ added in v1.1.0
type ViewListenerService struct {
// contains filtered or unexported fields
}
func NewViewListenerService ¶ added in v1.1.0
func NewViewListenerService(cs *Service, cm *ConnectionManager, dispatcher *event.DispatchService, logger logger.LogAdaptor) *ViewListenerService
Source Files ¶
- address_provider.go
- address_translator.go
- client_message.go
- cluster_service.go
- connection.go
- connection_bound_invocation.go
- connection_invocation_handler.go
- connection_listener_binder.go
- connection_listener_interface.go
- connection_manager.go
- connection_strategy.go
- error_codes.go
- events.go
- failover_service.go
- heartbeat_service.go
- invocation_factory.go
- member_bound_invocation.go
- partition_service.go
- view_listener_service.go