etcd

package
v1.12.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2015 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcquireLock

func AcquireLock(c *Client, key string, ttl uint64) error

AcquireLock creates a pseudo lock in etcd with a specific ttl

func Create

func Create(c *Client, key, value string, ttl uint64)

Create set the value of a key only if it does not exits

func Get

func Get(c *Client, key string) string

Get returns the value inside a key or an empty string

func GetHTTPEtcdUrls

func GetHTTPEtcdUrls(host, etcdPeers string) []string

GetHTTPEtcdUrls returns an array of urls that contains at least one host

func GetList

func GetList(c *Client, key string) []string

GetList returns the list of elements inside a key or an empty list

func Mkdir

func Mkdir(c *Client, path string)

Mkdir creates a directory only if does not exists

func PublishService

func PublishService(
	client *Client,
	etcdPath string,
	host string,
	externalPort int,
	ttl uint64,
	timeout time.Duration)

PublishService publish a service to etcd periodically

func ReleaseLock

func ReleaseLock(c *Client)

ReleaseLock releases the existing lock

func Set

func Set(c *Client, key, value string, ttl uint64)

Set sets the value of a key. If the ttl is bigger than 0 it will expire after the specified time

func SetDefault

func SetDefault(client *Client, key, value string)

SetDefault sets the value of a key without expiration

func WaitForKeys

func WaitForKeys(c *Client, keys []string, ttl time.Duration) error

WaitForKeys wait for the required keys up to the timeout or forever if is nil

Types

type Client

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

Client etcd client

func NewClient

func NewClient(machines []string) *Client

NewClient create a etcd client using the given machine list

type Error

type Error struct {
	ErrorCode int    `json:"errorCode"`
	Message   string `json:"message"`
	Cause     string `json:"cause,omitempty"`
	Index     uint64 `json:"index"`
}

Error etcd error

Jump to

Keyboard shortcuts

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