cluster

package
v1.0.0-preview.3 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2021 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EventConnectionOpened is dispatched when a connection to a member is opened.
	EventConnectionOpened = "internal.cluster.connectionopened"
	// EventConnectionClosed is dispatched when a connection to a member is closed.
	EventConnectionClosed = "internal.cluster.connectionclosed"

	// EventMembersAdded is dispatched when cluster service finds out new members are added to the cluster
	EventMembersAdded = "internal.cluster.membersadded"
	// EventMembersAdded is dispatched when cluster service finds out new members are removed from the cluster
	EventMembersRemoved = "internal.cluster.membersremoved"

	// EventConnected is dispatched after the very first connection to the cluster or the first connection after client disconnected.
	EventConnected = "internal.cluster.connected"

	// EventDisconnected is dispatched when all connections to the cluster are closed.
	EventDisconnected = "internal.cluster.disconnected"
)

Variables

View Source
var ClientVersion = "1.0.0"

ClientVersion is the build time version TODO: This should be replace with a build time version variable, BuildInfo etc.

Functions

func NewDefaultAddressTranslator

func NewDefaultAddressTranslator() *defaultAddressTranslator

func ParseAddress

func ParseAddress(addr string) (*pubcluster.AddressImpl, 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.AddressImpl)

func (AddrSet) AddAddrs

func (a AddrSet) AddAddrs(addrs []*pubcluster.AddressImpl)

func (AddrSet) Addrs

func (a AddrSet) Addrs() []*pubcluster.AddressImpl

type AddressProvider

type AddressProvider interface {
	Addresses() []*pubcluster.AddressImpl
}

type AddressTranslator

type AddressTranslator interface {

	// Translate translates the given address to another address specific
	// to network or service
	Translate(address *pubcluster.AddressImpl) *pubcluster.AddressImpl
}

AddressTranslator is used to resolve private ip address of cloud services.

type Connected

type Connected struct {
}

func NewConnected

func NewConnected() *Connected

func (*Connected) EventName

func (e *Connected) EventName() string

type ConnectedHandler

type ConnectedHandler func(event *Connected)

type Connection

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

func (*Connection) ConnectionID

func (c *Connection) ConnectionID() int64

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 ConnectionClosed

type ConnectionClosed struct {
	Conn *Connection
	Err  error
}

func NewConnectionClosed

func NewConnectionClosed(conn *Connection, err error) *ConnectionClosed

func (ConnectionClosed) EventName

func (c ConnectionClosed) EventName() string

type ConnectionClosedHandler

type ConnectionClosedHandler func(event *ConnectionClosed)

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,
	partitionID int32,
	address *pubcluster.AddressImpl,
	conn *Connection,
	handler proto.ClientMessageHandler) *ConnectionBoundInvocation

func (*ConnectionInvocationFactory) NewInvocationOnPartitionOwner

func (f *ConnectionInvocationFactory) NewInvocationOnPartitionOwner(message *proto.ClientMessage, partitionID int32) invocation.Invocation

func (*ConnectionInvocationFactory) NewInvocationOnRandomTarget

func (f *ConnectionInvocationFactory) NewInvocationOnRandomTarget(message *proto.ClientMessage, handler proto.ClientMessageHandler) invocation.Invocation

type ConnectionInvocationHandler

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

func (*ConnectionInvocationHandler) Invoke

type ConnectionInvocationHandlerCreationBundle

type ConnectionInvocationHandlerCreationBundle struct {
	ConnectionManager *ConnectionManager
	ClusterService    *Service
	Logger            ilogger.Logger
	Config            *pubcluster.Config
}

func (ConnectionInvocationHandlerCreationBundle) Check

type ConnectionListenerBinder

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

func NewConnectionListenerBinder

func NewConnectionListenerBinder(
	connManager *ConnectionManager,
	invocationFactory *ConnectionInvocationFactory,
	requestCh chan<- invocation.Invocation,
	removeCh chan<- int64,
	eventDispatcher *event.DispatchService,
	logger logger.Logger,
	smart bool) *ConnectionListenerBinder

func (*ConnectionListenerBinder) Add

func (*ConnectionListenerBinder) Remove

func (b *ConnectionListenerBinder) Remove(id types.UUID) error

type ConnectionManager

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

func (*ConnectionManager) ActiveConnections

func (m *ConnectionManager) ActiveConnections() []*Connection

func (*ConnectionManager) GetConnectionForAddress

func (m *ConnectionManager) GetConnectionForAddress(addr *pubcluster.AddressImpl) *Connection

func (*ConnectionManager) GetConnectionForPartition

func (m *ConnectionManager) GetConnectionForPartition(partitionID int32) *Connection

func (*ConnectionManager) NextConnectionID

func (m *ConnectionManager) NextConnectionID() int64

func (*ConnectionManager) RandomConnection

func (m *ConnectionManager) RandomConnection() *Connection

func (*ConnectionManager) Start

func (m *ConnectionManager) Start(timeout time.Duration) error

func (*ConnectionManager) Stop

func (m *ConnectionManager) Stop()

type ConnectionManagerCreationBundle

type ConnectionManagerCreationBundle struct {
	RequestCh            chan<- invocation.Invocation
	ResponseCh           chan<- *proto.ClientMessage
	Logger               ilogger.Logger
	ClusterService       *Service
	PartitionService     *PartitionService
	SerializationService *iserialization.Service
	EventDispatcher      *event.DispatchService
	InvocationFactory    *ConnectionInvocationFactory
	ClusterConfig        *pubcluster.Config
	Credentials          security.Credentials
	ClientName           string
}

func (ConnectionManagerCreationBundle) Check

type ConnectionOpened

type ConnectionOpened struct {
	Conn *Connection
}

func NewConnectionOpened

func NewConnectionOpened(conn *Connection) *ConnectionOpened

func (ConnectionOpened) EventName

func (c ConnectionOpened) EventName() string

type ConnectionOpenedHandler

type ConnectionOpenedHandler func(event *ConnectionOpened)

type CreationBundle

type CreationBundle struct {
	Logger            ilogger.Logger
	Config            *pubcluster.Config
	RequestCh         chan<- invocation.Invocation
	InvocationFactory *ConnectionInvocationFactory
	EventDispatcher   *event.DispatchService
	PartitionService  *PartitionService
	AddrProviders     []AddressProvider
}

func (CreationBundle) Check

func (b CreationBundle) Check()

type DefaultAddressProvider

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

func NewDefaultAddressProvider

func NewDefaultAddressProvider(networkConfig *pubcluster.Config) *DefaultAddressProvider

func (DefaultAddressProvider) Addresses

type Disconnected

type Disconnected struct {
}

func NewDisconnected

func NewDisconnected() *Disconnected

func (*Disconnected) EventName

func (c *Disconnected) EventName() string

type DisconnectedHandler

type DisconnectedHandler func(event *Disconnected)

type Listener

type Listener interface {
	ConnectionOpened(connection *Connection)
	ConnectionClosed(connection *Connection, err error)
}

type Member

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

func NewMember

func NewMember(address pubcluster.Address, uuid types.UUID, isLiteMember bool, attributes map[string]string, version pubcluster.MemberVersion, addressMap map[pubcluster.EndpointQualifier]pubcluster.Address) *Member

func (Member) Address

func (m Member) Address() pubcluster.Address

func (Member) Attributes

func (m Member) Attributes() map[string]string

func (*Member) Equal

func (m *Member) Equal(member2 Member) bool

func (*Member) HasSameAddress

func (m *Member) HasSameAddress(member *Member) bool

func (Member) LiteMember

func (m Member) LiteMember() bool

func (*Member) String

func (m *Member) String() string

func (Member) UUID

func (m Member) UUID() types.UUID

type MembersAdded

type MembersAdded struct {
	Members []pubcluster.Member
}

func NewMembersAdded

func NewMembersAdded(members []pubcluster.Member) *MembersAdded

func (MembersAdded) EventName

func (m MembersAdded) EventName() string

type MembersRemoved

type MembersRemoved struct {
	Members []pubcluster.Member
}

func NewMemberRemoved

func NewMemberRemoved(members []pubcluster.Member) *MembersRemoved

func (MembersRemoved) EventName

func (m MembersRemoved) EventName() string

type PartitionService

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

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

func (s *PartitionService) Update(connID int64, partitions []proto.Pair, version int32)

type PartitionServiceCreationBundle

type PartitionServiceCreationBundle struct {
	EventDispatcher *event.DispatchService
	Logger          ilogger.Logger
}

func (PartitionServiceCreationBundle) Check

type ResponseHandler

type ResponseHandler func(msg *proto.ClientMessage)

type Service

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

func NewServiceImpl

func NewServiceImpl(bundle CreationBundle) *Service

func (*Service) GetMemberByUUID

func (s *Service) GetMemberByUUID(uuid types.UUID) pubcluster.Member

func (*Service) MemberAddrs

func (s *Service) MemberAddrs() []string

func (*Service) Start

func (s *Service) Start()

func (*Service) Stop

func (s *Service) Stop()

Jump to

Keyboard shortcuts

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