Documentation
¶
Index ¶
- Variables
- type ClusterEventPublisher
- type Members
- func (m *Members) Add(member discovery.Member)
- func (m *Members) Delete(id uint64)
- func (m *Members) DeleteByName(other discovery.Member)
- func (m *Members) Get(id uint64) (discovery.Member, error)
- func (m *Members) Length() int
- func (m *Members) Range(f func(id uint64, member discovery.Member) bool)
- type RoutingTable
- func (r *RoutingTable) AddCallback(f func())
- func (r *RoutingTable) AddNodeJoinCallback(f func(nodeName string))
- func (r *RoutingTable) AddNodeLeaveCallback(f func(nodeName string))
- func (r *RoutingTable) CheckBootstrap() error
- func (r *RoutingTable) CheckMemberCountQuorum() error
- func (r *RoutingTable) Discovery() *discovery.Discovery
- func (r *RoutingTable) Generation() uint64
- func (r *RoutingTable) IsBootstrapped() bool
- func (r *RoutingTable) IsJoined() bool
- func (r *RoutingTable) Join() error
- func (r *RoutingTable) Members() *Members
- func (r *RoutingTable) NumMembers() int32
- func (r *RoutingTable) OwnedPartitionCount() uint64
- func (r *RoutingTable) PublishClusterEvent(ctx context.Context, channel, message string) error
- func (x *RoutingTable) PublishLocalClusterEvent(ctx context.Context, channel, message string) error
- func (r *RoutingTable) RegisterHandlers()
- func (r *RoutingTable) SendRebalanceAck(epoch uint64) error
- func (r *RoutingTable) SetClusterEventPublisher(publish ClusterEventPublisher)
- func (x *RoutingTable) SetLocalClusterEventPublisher(publish ClusterEventPublisher)
- func (r *RoutingTable) SetNumMembersEagerly(nr int32)
- func (r *RoutingTable) Shutdown(ctx context.Context) error
- func (r *RoutingTable) Signature() uint64
- func (r *RoutingTable) Start() error
- func (r *RoutingTable) This() discovery.Member
- func (r *RoutingTable) UpdateEagerly()
- func (r *RoutingTable) Version() (signature, generation uint64)
Constants ¶
This section is empty.
Variables ¶
var ( ErrServerGone = errors.New("server is gone") ErrNotJoinedYet = errors.New("not joined yet") ErrClusterJoin = errors.New("cannot join the cluster") // ErrOperationTimeout is returned when an operation times out. ErrOperationTimeout = errors.New("operation timeout") )
var ErrClusterQuorum = errors.New("cannot be reached cluster quorum to operate")
ErrClusterQuorum means that the cluster could not reach a healthy numbers of members to operate.
var ErrStaleRebalanceAck = errors.New("rebalance ack references a superseded epoch")
ErrStaleRebalanceAck is returned by SendRebalanceAck when the coordinator reports that the acked epoch has been superseded. The caller should re-run its balance cycle against the current routing table instead of retrying.
Functions ¶
This section is empty.
Types ¶
type ClusterEventPublisher ¶ added in v0.3.17
ClusterEventPublisher delivers an encoded cluster event to the subscribers of channel on every cluster member. The routing table has no publishing capability of its own: the pubsub service registers one at construction time via SetClusterEventPublisher.
type Members ¶
func (*Members) DeleteByName ¶
type RoutingTable ¶
func New ¶
func New(e *environment.Environment) *RoutingTable
func (*RoutingTable) AddCallback ¶
func (r *RoutingTable) AddCallback(f func())
func (*RoutingTable) AddNodeJoinCallback ¶ added in v0.3.16
func (r *RoutingTable) AddNodeJoinCallback(f func(nodeName string))
AddNodeJoinCallback registers a function that is called with the name (host:port) of every member that joins the cluster or is confirmed alive by a node-update event. It is the counterpart of AddNodeLeaveCallback: a leave callback that bans an address relies on this one to lift the ban when the member comes back. Same execution contract as AddNodeLeaveCallback.
func (*RoutingTable) AddNodeLeaveCallback ¶ added in v0.3.16
func (r *RoutingTable) AddNodeLeaveCallback(f func(nodeName string))
AddNodeLeaveCallback registers a function that is called with the name (host:port) of every member that leaves the cluster. Callbacks run synchronously on the membership event goroutine, in registration order and strictly in event order, and stop firing once the routing table shuts down. They must be fast and must not block: a slow callback stalls membership event processing. Register before Start; registration itself is safe at any time.
func (*RoutingTable) CheckBootstrap ¶
func (r *RoutingTable) CheckBootstrap() error
CheckBootstrap is called for every request and checks whether the node is bootstrapped. It has to be very fast for a smooth operation.
func (*RoutingTable) CheckMemberCountQuorum ¶
func (r *RoutingTable) CheckMemberCountQuorum() error
func (*RoutingTable) Discovery ¶
func (r *RoutingTable) Discovery() *discovery.Discovery
func (*RoutingTable) Generation ¶ added in v0.3.19
func (r *RoutingTable) Generation() uint64
Generation returns the generation of the installed routing table, zero before the first install. See tableVersion for how it relates to the signature.
func (*RoutingTable) IsBootstrapped ¶
func (r *RoutingTable) IsBootstrapped() bool
func (*RoutingTable) IsJoined ¶ added in v0.3.11
func (r *RoutingTable) IsJoined() bool
IsJoined reports whether this node has completed the cluster join. Observing the closed joined channel establishes a happens-before edge with the write of r.this in Join, so This() is safe to read once IsJoined returns true.
func (*RoutingTable) Join ¶
func (r *RoutingTable) Join() error
func (*RoutingTable) Members ¶
func (r *RoutingTable) Members() *Members
func (*RoutingTable) NumMembers ¶
func (r *RoutingTable) NumMembers() int32
func (*RoutingTable) OwnedPartitionCount ¶
func (r *RoutingTable) OwnedPartitionCount() uint64
func (*RoutingTable) PublishClusterEvent ¶ added in v0.3.17
func (r *RoutingTable) PublishClusterEvent(ctx context.Context, channel, message string) error
PublishClusterEvent delivers an encoded cluster event to the subscribers of channel on every cluster member through the registered publisher. Without a registered publisher — a deployment without the pubsub service, which only happens in partial test setups — the event is dropped.
func (*RoutingTable) PublishLocalClusterEvent ¶ added in v0.3.20
func (x *RoutingTable) PublishLocalClusterEvent(ctx context.Context, channel, message string) error
PublishLocalClusterEvent delivers an encoded cluster event to this member's own subscribers of channel, through the local publisher when one is registered and the cluster-wide one otherwise. Without either, the event is dropped.
func (*RoutingTable) RegisterHandlers ¶
func (r *RoutingTable) RegisterHandlers()
func (*RoutingTable) SendRebalanceAck ¶ added in v0.3.4
func (r *RoutingTable) SendRebalanceAck(epoch uint64) error
func (*RoutingTable) SetClusterEventPublisher ¶ added in v0.3.17
func (r *RoutingTable) SetClusterEventPublisher(publish ClusterEventPublisher)
SetClusterEventPublisher registers publish as the transport for cluster events. Until one is registered, PublishClusterEvent drops events.
func (*RoutingTable) SetLocalClusterEventPublisher ¶ added in v0.3.20
func (x *RoutingTable) SetLocalClusterEventPublisher(publish ClusterEventPublisher)
SetLocalClusterEventPublisher registers publish as the transport for the events a member delivers to its own subscribers only, node-join-event and node-left-event. Until one is registered those events go through the cluster-wide publisher, so a deployment or test that registers only that one still receives them.
func (*RoutingTable) SetNumMembersEagerly ¶
func (r *RoutingTable) SetNumMembersEagerly(nr int32)
func (*RoutingTable) Signature ¶
func (r *RoutingTable) Signature() uint64
Signature returns the signature of the installed routing table, zero before the first install.
func (*RoutingTable) Start ¶
func (r *RoutingTable) Start() error
func (*RoutingTable) This ¶
func (r *RoutingTable) This() discovery.Member
func (*RoutingTable) UpdateEagerly ¶
func (r *RoutingTable) UpdateEagerly()
func (*RoutingTable) Version ¶ added in v0.3.19
func (r *RoutingTable) Version() (signature, generation uint64)
Version returns the signature and generation of the installed routing table as one consistent snapshot. Consumers that key work on the generation but report the signature, such as the balancer's rebalance ack, must read both here rather than through Signature and Generation separately, otherwise an install landing between the two reads pairs a stale signature with a fresh generation.