etcd

package
v0.0.0-...-1d39891 Latest Latest
Warning

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

Go to latest
Published: May 12, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	KeysAPI etcd.KeysAPI
	// contains filtered or unexported fields
}

Client describes a ETCD configuration client

func NewClient

func NewClient(service common.Service, etcdServers []string, clientTimeout time.Duration) (*Client, error)

NewClient creates a new ETCD client connection to ETCD servers

func (*Client) GetInt64

func (client *Client) GetInt64(key string) (int64, error)

GetInt64 returns an int64 value from the configuration key

func (*Client) NewElection

func (client *Client) NewElection(name string) common.MasterElection

NewElection creates a new ETCD master elector

func (*Client) SetInt64

func (client *Client) SetInt64(key string, value int64) error

SetInt64 set an int64 value to the configuration key

func (*Client) Stop

func (client *Client) Stop()

Stop the client

type EmbeddedEtcd

type EmbeddedEtcd struct {
	Port int
	// contains filtered or unexported fields
}

EmbeddedEtcd provides a single node etcd server.

func NewEmbeddedEtcd

func NewEmbeddedEtcd(name string, listen string, peers map[string]string, dataDir string, maxWalFiles, maxSnapFiles uint, debug bool) (*EmbeddedEtcd, error)

NewEmbeddedEtcd creates a new embedded ETCD server

func (*EmbeddedEtcd) Stop

func (se *EmbeddedEtcd) Stop() error

Stop the embedded server

type MasterElector

type MasterElector struct {
	common.RWMutex
	EtcdKeyAPI etcd.KeysAPI
	Host       string
	// contains filtered or unexported fields
}

MasterElector describes an ETCD master elector

func NewMasterElector

func NewMasterElector(etcdClient *Client, key string) *MasterElector

NewMasterElector creates a new ETCD master elector

func (*MasterElector) AddEventListener

func (le *MasterElector) AddEventListener(listener common.MasterElectionListener)

AddEventListener registers a new listener

func (*MasterElector) IsMaster

func (le *MasterElector) IsMaster() bool

IsMaster returns true if the current instance is master

func (*MasterElector) Start

func (le *MasterElector) Start()

Start the master election mechanism

func (*MasterElector) StartAndWait

func (le *MasterElector) StartAndWait()

StartAndWait starts the election mechanism and wait for the first election before returning

func (*MasterElector) Stop

func (le *MasterElector) Stop()

Stop the election mechanism

func (*MasterElector) TTL

func (le *MasterElector) TTL() time.Duration

TTL time to live

Jump to

Keyboard shortcuts

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