etcd

package
v0.2.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2013 License: Apache-2.0, Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTP = iota
	HTTPS
)

Variables

View Source
var (
	ErrWatchStoppedByUser = errors.New("Watch stopped by the user via stop channel")
)

Errors introduced by the Watch command.

Functions

func CloseDebug

func CloseDebug()

func OpenDebug

func OpenDebug()

Types

type Client

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

func NewClient

func NewClient(machines []string) *Client

Setup a basic conf and cluster

func (*Client) Delete

func (c *Client) Delete(key string) (*Response, error)

func (*Client) Get

func (c *Client) Get(key string) ([]*Response, error)

func (*Client) GetCluster added in v0.2.0

func (c *Client) GetCluster() []string

func (*Client) GetFrom

func (c *Client) GetFrom(key string, addr string) ([]*Response, error)

GetTo gets the value of the key from a given machine address. If the given machine is not available it returns an error. Mainly use for testing purpose

func (*Client) Set

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

func (*Client) SetCertAndKey

func (c *Client) SetCertAndKey(cert string, key string) (bool, error)

func (*Client) SetCluster

func (c *Client) SetCluster(machines []string) bool

Try to sync from the given machine

func (*Client) SetScheme

func (c *Client) SetScheme(scheme int) (bool, error)

func (*Client) SetTo

func (c *Client) SetTo(key string, value string, ttl uint64, addr string) (*Response, error)

SetTo sets the value of the key to a given machine address. If the given machine is not available or is not leader it returns an error Mainly use for testing purpose.

func (*Client) SyncCluster

func (c *Client) SyncCluster() bool

sycn cluster information using the existing machine list

func (*Client) TestAndSet

func (c *Client) TestAndSet(key string, prevValue string, value string, ttl uint64) (*Response, bool, error)

func (*Client) Watch

func (c *Client) Watch(prefix string, sinceIndex uint64, receiver chan *Response, stop chan bool) (*Response, error)

type Cluster

type Cluster struct {
	Leader   string
	Machines []string
}

type Config

type Config struct {
	CertFile string
	KeyFile  string
	Scheme   string
	Timeout  time.Duration
}

type EtcdError

type EtcdError struct {
	ErrorCode int    `json:"errorCode"`
	Message   string `json:"message"`
	Cause     string `json:"cause,omitempty"`
}

func (EtcdError) Error

func (e EtcdError) Error() string

type Response added in v0.2.0

type Response struct {
	Action    string `json:"action"`
	Key       string `json:"key"`
	Dir       bool   `json:"dir,omitempty"`
	PrevValue string `json:"prevValue,omitempty"`
	Value     string `json:"value,omitempty"`

	// If the key did not exist before the action,
	// this field should be set to true
	NewKey bool `json:"newKey,omitempty"`

	Expiration *time.Time `json:"expiration,omitempty"`

	// Time to live in second
	TTL int64 `json:"ttl,omitempty"`

	// The command index of the raft machine when the command is executed
	Index uint64 `json:"index"`
}

The response object from the server.

Jump to

Keyboard shortcuts

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