package etcd
import "github.com/google/trillian/util/etcd"
Package etcd holds an etcd-specific implementation of the util.MasterElection interface.
Index ¶
- func NewClient(servers string) (*clientv3.Client, error)
- type ElectionFactory
- func NewElectionFactory(instanceID string, client *clientv3.Client, lockDir string) *ElectionFactory
- func (ef ElectionFactory) NewElection(ctx context.Context, treeID string) (election.MasterElection, error)
- type MasterElection
- func (eme *MasterElection) Close(ctx context.Context) error
- func (eme *MasterElection) GetCurrentMaster(ctx context.Context) (string, error)
- func (eme *MasterElection) IsMaster(ctx context.Context) (bool, error)
- func (eme *MasterElection) Resign(ctx context.Context) error
- func (eme *MasterElection) Start(ctx context.Context) error
- func (eme *MasterElection) WaitForMastership(ctx context.Context) error
Functions ¶
func NewClient ¶
NewClient returns an etcd client, or nil if servers is empty. The servers parameter should be a comma-separated list of etcd server URIs.
Types ¶
type ElectionFactory ¶
type ElectionFactory struct {
// contains filtered or unexported fields
}
ElectionFactory creates etcd.MasterElection instances.
func NewElectionFactory ¶
func NewElectionFactory(instanceID string, client *clientv3.Client, lockDir string) *ElectionFactory
NewElectionFactory builds an election factory that uses the given parameters. The passed in etcd client should remain valid for the lifetime of the ElectionFactory.
func (ElectionFactory) NewElection ¶
func (ef ElectionFactory) NewElection(ctx context.Context, treeID string) (election.MasterElection, error)
NewElection creates a specific etcd.MasterElection instance.
type MasterElection ¶
type MasterElection struct {
// contains filtered or unexported fields
}
MasterElection is an implementation of util.MasterElection based on etcd.
func (*MasterElection) Close ¶
func (eme *MasterElection) Close(ctx context.Context) error
Close terminates election operation.
func (*MasterElection) GetCurrentMaster ¶
func (eme *MasterElection) GetCurrentMaster(ctx context.Context) (string, error)
GetCurrentMaster returns the instanceID of the current master, if any.
func (*MasterElection) IsMaster ¶
func (eme *MasterElection) IsMaster(ctx context.Context) (bool, error)
IsMaster returns whether the current instance is the master.
func (*MasterElection) Resign ¶
func (eme *MasterElection) Resign(ctx context.Context) error
Resign releases mastership.
func (*MasterElection) Start ¶
func (eme *MasterElection) Start(ctx context.Context) error
Start commences election operation.
func (*MasterElection) WaitForMastership ¶
func (eme *MasterElection) WaitForMastership(ctx context.Context) error
WaitForMastership blocks until the current instance is master.
Source Files ¶
- Version
- v1.2.1
- Published
- Aug 16, 2018
- Platform
- js/wasm
- Imports
- 8 packages
- Last checked
- 5 hours ago –
Tools for package owners.