clientv3

package
v2.3.0-alpha.0....-145d5b8 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2016 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// KV is the keyvalue API for the client's connection.
	KV pb.KVClient
	// Lease is the lease API for the client's connection.
	Lease pb.LeaseClient
	// Watch is the watch API for the client's connection.
	Watch pb.WatchClient
	// Cluster is the cluster API for the client's connection.
	Cluster pb.ClusterClient
	// contains filtered or unexported fields
}

Client provides and manages an etcd v3 client session.

func New

func New(cfg Config) (*Client, error)

New creates a new etcdv3 client from a given configuration.

func NewFromConn

func NewFromConn(conn *grpc.ClientConn) *Client

NewFromConn creates a new etcdv3 client from an established grpc Connection.

func NewFromURL

func NewFromURL(url string) (*Client, error)

NewFromURL creates a new etcdv3 client from a URL.

func (*Client) Clone

func (c *Client) Clone() *Client

Clone creates a copy of client with the old connection and new API clients.

func (*Client) Close

func (c *Client) Close() error

Close shuts down the client's etcd connections.

func (*Client) Dial

func (c *Client) Dial(endpoint string) (*grpc.ClientConn, error)

Dial establishes a connection for a given endpoint using the client's config

func (*Client) Endpoints

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

Endpoints lists the registered endpoints for the client.

func (*Client) Errors

func (c *Client) Errors() (errs []error)

Errors returns all errors that have been observed since called last.

type Compare

type Compare struct {
}

type Config

type Config struct {
	// Endpoints is a list of URLs
	Endpoints []string

	// RetryDialer chooses the next endpoint to use
	RetryDialer EndpointDialer
}

type DeleteRangeResponse

type DeleteRangeResponse pb.DeleteRangeResponse

type DeleteResponse

type DeleteResponse pb.DeleteRangeResponse

type EndpointDialer

type EndpointDialer func(*Client) (*grpc.ClientConn, error)

EndpointDialer is a policy for choosing which endpoint to dial next

type GetResponse

type GetResponse pb.RangeResponse

type KV

type KV interface {
	// PUT puts a key-value pair into etcd.
	// Note that key,value can be plain bytes array and string is
	// an immutable representation of that bytes array.
	// To get a string of bytes, do string([]byte(0x10, 0x20)).
	Put(key, val string) (*PutResponse, error)

	// Range gets the keys [key, end) in the range at rev.
	// If revev <=0, range gets the keys at currentRev.
	// Limit limits the number of keys returned.
	// If the required rev is compacted, ErrCompacted will be returned.
	Range(key, end string, limit, rev int64, sort *SortOption) (*RangeResponse, error)

	// Get is like Range. A shortcut for ranging single key like [key, key+1).
	Get(key, rev int64) (*GetResponse, error)

	// DeleteRange deletes the given range [key, end).
	DeleteRange(key, end string) (*DeleteRangeResponse, error)

	// Delete is like DeleteRange. A shortcut for deleting single key like [key, key+1).
	Delete(key string) (*DeleteResponse, error)

	// Compact compacts etcd KV history before the given rev.
	Compact(rev int64) error

	// Txn creates a transaction.
	Txn() Txn
}

type Op

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

Op represents an Operation that kv can execute.

func OpDelete

func OpDelete(key string) Op

func OpDeleteRange

func OpDeleteRange(key, end string) Op

func OpGet

func OpGet(key string, rev int64) Op

func OpRange

func OpRange(key, end string, limit, rev int64, sort *SortOption) Op

type PutResponse

type PutResponse pb.PutResponse

type RangeResponse

type RangeResponse pb.RangeResponse

type SortOption

type SortOption struct {
	Target SortTarget
	Order  SortOrder
}

type SortOrder

type SortOrder int

type SortTarget

type SortTarget int

type Txn

type Txn interface {
	// If takes a list of comparison. If all comparisons passed in succeed,
	// the operations passed into Then() will be executed. Or the operations
	// passed into Else() will be executed.
	If(cs ...Compare) Txn

	// Then takes a list of operations. The Ops list will be executed, if the
	// comparisons passed in If() succeed.
	Then(ops ...Op) Txn

	// Else takes a list of operations. The Ops list will be executed, if the
	// comparisons passed in If() fail.
	Else(ops ...Op) Txn

	// Commit tries to commit the transaction.
	Commit() (*TxnResponse, error)
}

Tx.If(

CmpValue(k1, ">", v1),
CmpVersion(k1, "=", 2)

).Then(

OpPut(k2,v2), OpPut(k3,v3)

).Else(

OpPut(k4,v4), OpPut(k5,v5)

).Commit()

type TxnResponse

type TxnResponse pb.TxnResponse

Jump to

Keyboard shortcuts

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