Documentation ¶
Index ¶
- Variables
- type GetLeaderAddrResp
- type LeaderWatcher
- type LeadershipChecker
- type LeadershipEventCallbacks
- type Member
- func (m *Member) CampaignAndKeepLeader(ctx context.Context, leaseTTLSec int64, leadershipChecker LeadershipChecker, ...) 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
}
LeaderWatcher watches the changes of the CeresMeta cluster's leadership.
func NewLeaderWatcher ¶
func NewLeaderWatcher(ctx WatchContext, self *Member, leaseTTLSec int64, embedEtcd bool) *LeaderWatcher
func (*LeaderWatcher) Watch ¶
func (l *LeaderWatcher) Watch(ctx context.Context, callbacks LeadershipEventCallbacks)
Watch watches the leader changes:
- Check whether the leader is valid 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. - Campaign the leader if this member should. - 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 LeadershipChecker ¶ added in v1.2.7
type LeadershipChecker interface { ShouldCampaign(self *Member) bool IsValidLeader(memLeader *metastoragepb.Member) bool }
LeadershipChecker tells which member should campaign the CeresMeta cluster's leadership, and whether the current leader is valid.
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 (m *Member) CampaignAndKeepLeader(ctx context.Context, leaseTTLSec int64, leadershipChecker LeadershipChecker, callbacks LeadershipEventCallbacks) error
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.