Documentation ¶
Index ¶
- Constants
- Variables
- func CloseDebug()
- func OpenDebug()
- type Client
- func (c *Client) AddChild(key string, value string, ttl uint64) (*Response, error)
- func (c *Client) AddChildDir(key string, ttl uint64) (*Response, error)
- func (c *Client) CloseCURL()
- func (c *Client) CompareAndSwap(key string, value string, ttl uint64, prevValue string, prevIndex uint64) (*Response, error)
- func (c *Client) Create(key string, value string, ttl uint64) (*Response, error)
- func (c *Client) CreateDir(key string, ttl uint64) (*Response, error)
- func (c *Client) Delete(key string, recursive bool) (*Response, error)
- func (c *Client) DeleteRaw(key string, recursive bool) (*RawResponse, error)
- func (c *Client) Get(key string, sort, recursive bool) (*Response, error)
- func (c *Client) GetCluster() []string
- func (c *Client) MarshalJSON() ([]byte, error)
- func (c *Client) OpenCURL()
- func (c *Client) RawCreate(key string, value string, ttl uint64) (*RawResponse, error)
- func (c *Client) RawCreateDir(key string, ttl uint64) (*RawResponse, error)
- func (c *Client) RawGet(key string, sort, recursive bool) (*RawResponse, error)
- func (c *Client) RawSet(key string, value string, ttl uint64) (*RawResponse, error)
- func (c *Client) RawSetDir(key string, ttl uint64) (*RawResponse, error)
- func (c *Client) RawUpdate(key string, value string, ttl uint64) (*RawResponse, error)
- func (c *Client) RawUpdateDir(key string, ttl uint64) (*RawResponse, error)
- func (c *Client) RawWatch(prefix string, waitIndex uint64, recursive bool, receiver chan *RawResponse, ...) (*RawResponse, error)
- func (c *Client) RecvCURL() string
- func (c *Client) Set(key string, value string, ttl uint64) (*Response, error)
- func (c *Client) SetCertAndKey(cert string, key string) error
- func (c *Client) SetCluster(machines []string) bool
- func (c *Client) SetConsistency(consistency string) error
- func (c *Client) SetDir(key string, ttl uint64) (*Response, error)
- func (c *Client) SetPersistence(writer io.Writer)
- func (c *Client) SetScheme(scheme int) error
- func (c *Client) SyncCluster() bool
- func (c *Client) UnmarshalJSON(b []byte) error
- func (c *Client) Update(key string, value string, ttl uint64) (*Response, error)
- func (c *Client) UpdateDir(key string, ttl uint64) (*Response, error)
- func (c *Client) Watch(prefix string, waitIndex uint64, recursive bool, receiver chan *Response, ...) (*Response, error)
- type Cluster
- type Config
- type EtcdError
- type Node
- type Nodes
- type RawResponse
- type Response
Constants ¶
const ( HTTP = iota HTTPS )
const ( // Using strings rather than iota because the consistency level // could be persisted to disk, so it'd be better to use // human-readable values. STRONG_CONSISTENCY = "STRONG" WEAK_CONSISTENCY = "WEAK" )
See SetConsistency for how to use these constants.
Variables ¶
var ( VALID_GET_OPTIONS = validOptions{ "recursive": reflect.Bool, "consistent": reflect.Bool, "sorted": reflect.Bool, "wait": reflect.Bool, "waitIndex": reflect.Uint64, } VALID_PUT_OPTIONS = validOptions{ "prevValue": reflect.String, "prevIndex": reflect.Uint64, "prevExist": reflect.Bool, } VALID_POST_OPTIONS = validOptions{} VALID_DELETE_OPTIONS = validOptions{ "recursive": reflect.Bool, } )
Valid options for GET, PUT, POST, DELETE Using CAPITALIZED_UNDERSCORE to emphasize that these values are meant to be used as constants.
var (
ErrWatchStoppedByUser = errors.New("Watch stopped by the user via stop channel")
)
Errors introduced by the Watch command.
Functions ¶
func CloseDebug ¶
func CloseDebug()
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
NewClient create a basic client that is configured to be used with the given machine list.
func NewClientFile ¶ added in v0.2.0
NewClientFile creates a client from a given file path. The given file is expected to use the JSON format.
func NewClientReader ¶ added in v0.2.0
NewClientReader creates a Client configured from a given reader. The config is expected to use the JSON format.
func (*Client) AddChild ¶ added in v0.2.0
Add a new file with a random etcd-generated key under the given path.
func (*Client) AddChildDir ¶ added in v0.2.0
Add a new directory with a random etcd-generated key under the given path.
func (*Client) CompareAndSwap ¶ added in v0.2.0
func (*Client) Create ¶ added in v0.2.0
Create creates a file with the given value under the given key. It succeeds only if the given key does not yet exist.
func (*Client) CreateDir ¶ added in v0.2.0
UpdateDir creates a directory under the given key. It succeeds only if the given key does not yet exist.
func (*Client) Delete ¶
Delete deletes the given key. When recursive set to false If the key points to a directory, the method will fail. When recursive set to true, if the key points to a file, the file will be deleted. If the key points to a directory, then everything under the directory, including all child directories, will be deleted.
func (*Client) DeleteRaw ¶ added in v0.2.0
func (c *Client) DeleteRaw(key string, recursive bool) (*RawResponse, error)
func (*Client) Get ¶
Get gets the file or directory associated with the given key. If the key points to a directory, files and directories under it will be returned in sorted or unsorted order, depending on the sort flag. If recursive is set to false, contents under child directories will not be returned. If recursive is set to true, all the contents will be returned.
func (*Client) GetCluster ¶ added in v0.2.0
func (*Client) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements the Marshaller interface as defined by the standard JSON package.
func (*Client) RawCreateDir ¶ added in v0.2.0
func (c *Client) RawCreateDir(key string, ttl uint64) (*RawResponse, error)
func (*Client) RawGet ¶ added in v0.2.0
func (c *Client) RawGet(key string, sort, recursive bool) (*RawResponse, error)
func (*Client) RawSetDir ¶ added in v0.2.0
func (c *Client) RawSetDir(key string, ttl uint64) (*RawResponse, error)
func (*Client) RawUpdateDir ¶ added in v0.2.0
func (c *Client) RawUpdateDir(key string, ttl uint64) (*RawResponse, error)
func (*Client) RawWatch ¶ added in v0.2.0
func (c *Client) RawWatch(prefix string, waitIndex uint64, recursive bool, receiver chan *RawResponse, stop chan bool) (*RawResponse, error)
func (*Client) SetCluster ¶
SetCluster updates config using the given machine list.
func (*Client) SetConsistency ¶ added in v0.2.0
SetConsistency changes the consistency level of the client.
When consistency is set to STRONG_CONSISTENCY, all requests, including GET, are sent to the leader. This means that, assuming the absence of leader failures, GET requests are guaranteed to see the changes made by previous requests.
When consistency is set to WEAK_CONSISTENCY, other requests are still sent to the leader, but GET requests are sent to a random server from the server pool. This reduces the read load on the leader, but it's not guaranteed that the GET requests will see changes made by previous requests (they might have not yet been committed on non-leader servers).
func (*Client) SetPersistence ¶ added in v0.2.0
SetPersistence sets a writer to which the config will be written every time it's changed.
func (*Client) SyncCluster ¶
SyncCluster updates config using the internal machine list.
func (*Client) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements the Unmarshaller interface as defined by the standard JSON package.
func (*Client) Update ¶ added in v0.2.0
Update updates the given key to the given value. It succeeds only if the given key already exists.
func (*Client) UpdateDir ¶ added in v0.2.0
UpdateDir updates the given key to a directory. It succeeds only if the given key already exists.
func (*Client) Watch ¶
func (c *Client) Watch(prefix string, waitIndex uint64, recursive bool, receiver chan *Response, stop chan bool) (*Response, error)
If recursive is set to true the watch returns the first change under the given prefix since the given index.
If recursive is set to false the watch returns the first change to the given key since the given index.
To watch for the latest change, set waitIndex = 0.
If a receiver channel is given, it will be a long-term watch. Watch will block at the channel. After someone receives the channel, it will go on to watch that prefix. If a stop channel is given, the client can close long-term watch using the stop channel.
type EtcdError ¶
type Node ¶ added in v0.2.0
type Node struct { Key string `json:"key, omitempty"` PrevValue string `json:"prevValue,omitempty"` Value string `json:"value,omitempty"` Dir bool `json:"dir,omitempty"` Expiration *time.Time `json:"expiration,omitempty"` TTL int64 `json:"ttl,omitempty"` Nodes Nodes `json:"nodes,omitempty"` ModifiedIndex uint64 `json:"modifiedIndex,omitempty"` CreatedIndex uint64 `json:"createdIndex,omitempty"` }