etcd/clientv3
Gyu-Ho Lee 8f7948641c contrib/recipes: replace WatchPrefix with Watch 2016-02-23 20:02:24 -08:00
..
integration clientv3: combine Watch, WatchPrefix with variadic 2016-02-23 20:02:21 -08:00
sync clientv3: combine Watch, WatchPrefix with variadic 2016-02-23 20:02:21 -08:00
README.md clientv3: add more code examples 2016-02-23 14:05:36 -08:00
client.go *: exported godoc fixups 2016-02-21 20:36:44 -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: add more code examples 2016-02-23 14:05:36 -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: combine Watch, WatchPrefix with variadic 2016-02-23 20:02:21 -08:00
kv.go clientv3: kv.Delete typo 2016-02-23 15:07:10 -08:00
lease.go clientv3: support context cancellation on lease keep alives 2016-02-20 23:21:15 -08:00
op.go clientv3: combine Watch, WatchPrefix with variadic 2016-02-23 20:02:21 -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 contrib/recipes: replace WatchPrefix with Watch 2016-02-23 20:02:24 -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.