etcd

package
v3.3.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2018 License: Apache-2.0 Imports: 25 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMemberRevisionTooOld = errors.New("member revision older than the minimum desired revision")

Functions

func ClientURL

func ClientURL(address string, tlsEnabled bool) string

func ClientsURLs

func ClientsURLs(addresses []string, tlsEnabled bool) (cURLs []string)

func URL2Address

func URL2Address(pURL string) string

Types

type Client

type Client struct {
	*clientv3.Client

	SC SecurityConfig
	TC *tls.Config
	// contains filtered or unexported fields
}

func NewClient

func NewClient(clientsAddresses []string, sc SecurityConfig, autoSync bool) (*Client, error)

NewClient creates a new etcd client wrapper.

The client must be closed.

func (*Client) AddMember

func (c *Client) AddMember(name string, pURLs []string) (uint64, func(), error)

func (*Client) Cleanup

func (c *Client) Cleanup() error

func (*Client) ForEachMember

func (c *Client) ForEachMember(f func(*Client, *etcdserverpb.Member) error) error

func (*Client) GetHighestRevision

func (c *Client) GetHighestRevision() (int64, error)

func (*Client) GetRevisionsHashes

func (c *Client) GetRevisionsHashes() (map[string]int64, map[string]int64, error)

func (*Client) IsConsistent

func (c *Client) IsConsistent() error

func (*Client) IsHealthy

func (c *Client) IsHealthy(retries int, timeout time.Duration) bool

IsHealthy verifies if the cluster is healthy / has quorum, or when a single address is given and autoSync is off, if the member behind that address is responsive (and not that the overall cluster is operating).

For checking the health of the entire cluster, IsHealthy simply leverages linearizable reads, which are reads that must go through raft. Even if a few members are unreachable or isolated, IsHealthy is able to respond correctly thanks to the smart underlying balancer in the client.

func (*Client) Lock

func (c *Client) Lock(name string, maxWait time.Duration) (func(), error)

func (*Client) Members

func (c *Client) Members() ([]*etcdserverpb.Member, error)

func (*Client) RemoveMember

func (c *Client) RemoveMember(name string, id uint64) error

type EtcdConfiguration

type EtcdConfiguration struct {
	AdvertiseAddress        string         `yaml:"advertise-address"`
	DataDir                 string         `yaml:"data-dir"`
	ClientTransportSecurity SecurityConfig `yaml:"client-transport-security"`
	PeerTransportSecurity   SecurityConfig `yaml:"peer-transport-security"`
	BackendQuota            int64          `yaml:"backend-quota"`
}

EtcdConfiguration contains the configuration related to the underlying etcd server.

type SecurityConfig

type SecurityConfig struct {
	CAFile        string `yaml:"ca-file"`
	CertFile      string `yaml:"cert-file"`
	KeyFile       string `yaml:"key-file"`
	CertAuth      bool   `yaml:"client-cert-auth"`
	TrustedCAFile string `yaml:"trusted-ca-file"`
	AutoTLS       bool   `yaml:"auto-tls"`
}

func (SecurityConfig) ClientConfig

func (sc SecurityConfig) ClientConfig() (*tls.Config, error)

func (SecurityConfig) TLSEnabled

func (sc SecurityConfig) TLSEnabled() bool

func (SecurityConfig) TLSInfo

func (sc SecurityConfig) TLSInfo() transport.TLSInfo

type Server

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

func NewServer

func NewServer(cfg ServerConfig) *Server

func (*Server) IsRunning

func (c *Server) IsRunning() bool

func (*Server) Join

func (c *Server) Join(cluster *Client) error

func (*Server) Restore

func (c *Server) Restore(metadata *snapshot.Metadata) error

func (*Server) Seed

func (c *Server) Seed(snapshot *snapshot.Metadata) error

func (*Server) Snapshot

func (c *Server) Snapshot() error

func (*Server) SnapshotInfo

func (c *Server) SnapshotInfo() (*snapshot.Metadata, error)

func (*Server) Stop

func (c *Server) Stop(graceful, snapshot bool)

type ServerConfig

type ServerConfig struct {
	Name               string
	DataDir            string
	DataQuota          int64
	PublicAddress      string
	PrivateAddress     string
	ClientSC           SecurityConfig
	PeerSC             SecurityConfig
	UnhealthyMemberTTL time.Duration

	// Optional, used in {Seed, Join} to periodically save snapshots.
	SnapshotProvider snapshot.Provider
	SnapshotInterval time.Duration
	SnapshotTTL      time.Duration
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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