Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNonLeader = errors.New("the elector is not leader") ErrClosed = errors.New("the elector is already closed") ErrPingEtcd = errors.New("ping etcd server timeout") )
View Source
var ( // alias options WithTTL = concurrency.WithTTL WithContext = concurrency.WithContext WithLease = concurrency.WithLease )
Functions ¶
This section is empty.
Types ¶
type Elector ¶
type Elector struct {
// contains filtered or unexported fields
}
func NewElector ¶
func NewElector(ctx context.Context, cfg clientv3.Config, options ...concurrency.SessionOption) (*Elector, error)
func NewElectorWithClient ¶
func NewElectorWithClient(ctx context.Context, cli *clientv3.Client, options ...concurrency.SessionOption) (*Elector, error)
func (*Elector) GetLeaderID ¶
func (*Elector) Start ¶
Start Start the election. This method will keep trying the election. When the election is successful, set isleader to true. If it fails, the election directory will be monitored until the election is successful. The parameter electionPath is used to specify the etcd directory for the operation.
Click to show internal directories.
Click to hide internal directories.