etcd

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package etcd holds an etcd-specific implementation of the util.MasterElection interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(servers string) (*clientv3.Client, error)

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.

func (ElectionFactory) NewElection

func (ef ElectionFactory) NewElection(ctx context.Context, treeID int64) (util.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) IsMaster

func (eme *MasterElection) IsMaster(ctx context.Context) (bool, error)

IsMaster returns whether the current instance is the master.

func (*MasterElection) ResignAndRestart

func (eme *MasterElection) ResignAndRestart(ctx context.Context) error

ResignAndRestart releases mastership, and re-joins the election.

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.

Jump to

Keyboard shortcuts

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