etcd

package
v0.0.0-...-a355528 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// RunContainer is a command that shells out to Docker to run the etcd server in a container
	RunContainer = exec.Command(`
docker run --rm -d \
       -v /usr/share/ca-certificates/:/etc/ssl/certs \
       -p 4001:4001 \
       -p 2380:2380 \
       -p 2379:2379 \
       --name {{ arg 2 }} \
       quay.io/coreos/etcd etcd \
       -debug \
       -name etcd0 \
       -advertise-client-urls http://{{ arg 1 }}:2379,http://{{ arg 1 }}:4001 \
       -listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
       -initial-advertise-peer-urls http://{{ arg 1 }}:2380 \
       -listen-peer-urls http://0.0.0.0:2380 \
       -initial-cluster-token etcd-cluster-1 \
       -initial-cluster etcd0=http://{{ arg 1 }}:2380 \
       -initial-cluster-state new
`)

	// StopContainer stops the etcd container
	StopContainer = exec.Command(`docker stop {{ arg 1 }}`)

	// LsMembers lists the members in the cluster
	LsMembers = exec.Command(`
docker run --rm -e ETCDCTL_API=3 \
       quay.io/coreos/etcd etcdctl --endpoints={{ arg 1 }}:2379 member list
`)

	// Get fetches a value via etcdctl
	Get = exec.Command(`
docker run --rm -e ETCDCTL_API=3 \
       quay.io/coreos/etcd etcdctl --endpoints={{ arg 1 }}:2379 get --print-value-only {{ arg 2 }}
`)
)

Functions

func LocalIP

func LocalIP() string

LocalIP returns the first non loopback local IP of the host

Types

type Client

type Client struct {
	Client  *clientv3.Client
	Options Options
}

Client is a wrapper for etcd

func NewClient

func NewClient(options Options) (*Client, error)

NewClient returns a client

func (*Client) Close

func (c *Client) Close() error

Close closes the connection

type Options

type Options struct {
	clientv3.Config

	// RequestTimeout is used for all requests to etcd
	RequestTimeout time.Duration
}

Options is for configuring the snapshot client

Jump to

Keyboard shortcuts

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