member

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

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 GetLeaderAddrResp struct {
	LeaderEndpoint string
	IsLocal        bool
}

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:

  1. 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.
  2. 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 LeadershipEventCallbacks

type LeadershipEventCallbacks interface {
	AfterElected(ctx context.Context)
	BeforeTransfer(ctx context.Context)
}

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 NewMember

func NewMember(rootPath string, id uint64, name, endpoint string, etcdCli *clientv3.Client, etcdLeaderGetter etcdutil.EtcdLeaderGetter, rpcTimeout time.Duration) *Member

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.

func (*Member) Marshal

func (m *Member) Marshal() (string, error)

func (*Member) ResetLeader

func (m *Member) ResetLeader(ctx context.Context) error

func (*Member) WaitForLeaderChange

func (m *Member) WaitForLeaderChange(ctx context.Context, revision int64)

type WatchContext

type WatchContext interface {
	etcdutil.EtcdLeaderGetter
	ShouldStop() bool
}

Jump to

Keyboard shortcuts

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