Documentation ¶
Index ¶
- Variables
- type GetLeaderAddrResp
- type LeaderWatcher
- type LeadershipEventCallbacks
- type Member
- func (m *Member) CampaignAndKeepLeader(ctx context.Context, leaseTTLSec int64, callbacks LeadershipEventCallbacks) error
- func (m *Member) GetLeaderAddr(_ context.Context) (GetLeaderAddrResp, error)
- func (m *Member) Marshal() (string, error)
- func (m *Member) ResetLeader(ctx context.Context) error
- func (m *Member) WaitForLeaderChange(ctx context.Context, revision int64)
- type WatchContext
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrResetLeader = coderr.NewCodeError(coderr.Internal, "reset leader by deleting leader key") ErrGetLeader = coderr.NewCodeError(coderr.Internal, "get leader by querying leader key") ErrTxnPutLeader = coderr.NewCodeError(coderr.Internal, "put leader key in txn") ErrMultipleLeader = coderr.NewCodeError(coderr.Internal, "multiple leaders found") ErrInvalidLeaderValue = coderr.NewCodeError(coderr.Internal, "invalid leader value") ErrMarshalMember = coderr.NewCodeError(coderr.Internal, "marshal member information") ErrGrantLease = coderr.NewCodeError(coderr.Internal, "grant lease") ErrRevokeLease = coderr.NewCodeError(coderr.Internal, "revoke lease") ErrCloseLease = coderr.NewCodeError(coderr.Internal, "close lease") )
Functions ¶
This section is empty.
Types ¶
type GetLeaderAddrResp ¶ added in v1.2.1
type LeaderWatcher ¶
type LeaderWatcher struct {
// contains filtered or unexported fields
}
func NewLeaderWatcher ¶
func NewLeaderWatcher(ctx WatchContext, self *Member, leaseTTLSec int64) *LeaderWatcher
func (*LeaderWatcher) Watch ¶
func (l *LeaderWatcher) Watch(ctx context.Context, callbacks LeadershipEventCallbacks)
Watch watches the leader changes:
- Check whether the leader is valid (same as the etcd leader) if leader exists. - Leader is valid: wait for the leader changes. - Leader is not valid: reset the leader by the current leader.
- Campaign the leadership if leader does not exist. - Elect the etcd leader as the ceresmeta leader. - The leader keeps the leadership lease alive. - The other members keeps waiting for the leader changes.
The LeadershipCallbacks `callbacks` will be triggered when specific events occur.
type Member ¶
type Member struct { ID uint64 Name string Endpoint string // contains filtered or unexported fields }
Member manages the leadership and the role of the node in the ceresmeta cluster.
func (*Member) CampaignAndKeepLeader ¶
func (*Member) GetLeaderAddr ¶ added in v1.2.1
func (m *Member) GetLeaderAddr(_ context.Context) (GetLeaderAddrResp, error)
GetLeaderAddr gets the leader address of the cluster with memory cache. return error if no leader found.
type WatchContext ¶
type WatchContext interface { etcdutil.EtcdLeaderGetter ShouldStop() bool }
Click to show internal directories.
Click to hide internal directories.