etcd/clientv3
Anthony Romano d430c7baf7 clientv3: use default client watcher 2016-02-25 18:13:26 -08:00
..
concurrency clientv3: use default client watcher 2016-02-25 18:13:26 -08:00
integration *: watch true cancel, created for wrong rev 2016-02-24 20:56:17 -08:00
mirror clientv3: use default client watcher 2016-02-25 18:13:26 -08:00
README.md clientv3: add more code examples 2016-02-23 14:05:36 -08:00
client.go clientv3: compose all clientv3 APIs into client struct 2016-02-25 18:13:26 -08:00
client_test.go *: fix minor typos, comments 2016-01-30 18:15:56 -08:00
cluster.go clientv3: fix godoc for member apis 2016-02-11 13:55:38 -08:00
compare.go clientv3: make compare compliant with proposed txn usage 2016-02-08 13:48:29 -08:00
doc.go clientv3: add more code examples 2016-02-23 14:05:36 -08:00
example_cluster_test.go clientv3: add more code examples 2016-02-23 14:05:36 -08:00
example_kv_test.go clientv3: expose Do in KV 2016-02-25 17:33:47 -08:00
example_lease_test.go clientv3: add more code examples 2016-02-23 14:05:36 -08:00
example_test.go clientv3: add more code examples 2016-02-23 14:05:36 -08:00
example_watch_test.go clientv3: use default client watcher 2016-02-25 18:13:26 -08:00
kv.go clientv3: expose Do in KV 2016-02-25 17:33:47 -08:00
lease.go clientv3: respect first stream error in lease recv loop 2016-02-25 16:59:08 -08:00
op.go clientv3/concurrency: Mutex 2016-02-24 17:23:40 -08:00
sort.go clientv3: fill in kv ops 2016-01-28 08:17:53 -08:00
txn.go clientv3: copy correct pointers into txn comparisons 2016-02-20 22:01:33 -08:00
txn_test.go clientv3: optionize put and delete 2016-02-10 15:03:11 -08:00
watch.go *: watch true cancel, created for wrong rev 2016-02-24 20:56:17 -08:00

README.md

etcd/clientv3

Godoc

etcd/clientv3 is the official Go etcd client for v3.

Install

go get github.com/coreos/etcd/clientv3

Get started

Create client using clientv3.New:

cli, err := clientv3.New(clientv3.Config{
	Endpoints:   []string{"localhost:12378", "localhost:22378", "localhost:32378"},
	DialTimeout: 5 * time.Second,
})
if err != nil {
	// handle error!
}
defer cli.Close()

etcd v3 uses gRPC for remote procedure calls. And clientv3 uses grpc-go to connect to etcd. Make sure to close the client after using it. If the client is not closed, the connection will have leaky goroutines. To specify client request timeout, pass context.WithTimeout to APIs:

ctx, cancel := context.WithTimeout(context.Background(), timeout)
resp, err := kvc.Put(ctx, "sample_key", "sample_value")
cancel()
if err != nil {
    // handle error!
}
// use the response

Error Handling

TODO

Examples

More code examples can be found at GoDoc.