etcd

package
v1.0.20 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package etcd provides an implementation of master election based on etcd.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Election

type Election struct {
	// contains filtered or unexported fields
}

Election is an implementation of election.Election based on etcd.

func (*Election) Await

func (e *Election) Await(ctx context.Context) error

Await blocks until the instance captures mastership.

func (*Election) Close

func (e *Election) Close(ctx context.Context) error

Close resigns and permanently stops participating in election. No other method should be called after Close.

func (*Election) Observe

func (e *Election) Observe(ctx context.Context) (context.Context, error)

Observe returns a "mastership context" which remains active until the instance stops being the master, or the passed in context is canceled.

func (*Election) Resign

func (e *Election) Resign(ctx context.Context) error

Resign releases mastership for this instance. The instance can be elected again using Await. Idempotent, might be useful to retry if fails.

type Factory

type Factory struct {
	// contains filtered or unexported fields
}

Factory creates Election instances.

func NewFactory

func NewFactory(instanceID string, client *clientv3.Client, lockDir string) *Factory

NewFactory builds an election factory that uses the given parameters. The passed in etcd client should remain valid for the lifetime of the object.

func (*Factory) NewElection

func (f *Factory) NewElection(ctx context.Context, treeID int64) (election.Election, error)

NewElection creates a specific Election instance.

Jump to

Keyboard shortcuts

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