mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00

In the sample code demonstrating how to specify a client request timeout, the `cancel()` is called immediately after the Put, but it should be deferred instead, giving the Put enough time to complete. In the canonical Golang context [docs](https://pkg.go.dev/context#WithTimeout), the sample code sets a `defer cancel()` immediately after context creation, and with this commit we adhere to that convention. fixes: ```json { "level": "warn", "ts": "2021-12-29T09:56:42.439-0800", "logger": "etcd-client", "caller": "v3@v3.5.1/retry_interceptor.go:62", "msg": "retrying of unary invoker failed", "target": "etcd-endpoints://0xc000213340/localhost:2379", "attempt": 0, "error": "rpc error: code = Canceled desc = context canceled" } ```