mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdctl: add per request timeout
This commit is contained in:
parent
1fe52e1ec3
commit
e36c499d0f
@ -47,7 +47,6 @@ func getCommandFunc(c *cli.Context, ki client.KeysAPI) {
|
||||
key := c.Args()[0]
|
||||
sorted := c.Bool("sort")
|
||||
|
||||
// TODO: handle transport timeout
|
||||
resp, err := ki.Get(context.TODO(), key, &client.GetOptions{Sort: sorted})
|
||||
if err != nil {
|
||||
handleError(ExitServerError, err)
|
||||
|
@ -47,7 +47,6 @@ func lsCommandFunc(c *cli.Context, ki client.KeysAPI) {
|
||||
sort := c.Bool("sort")
|
||||
recursive := c.Bool("recursive")
|
||||
|
||||
// TODO: handle transport timeout
|
||||
resp, err := ki.Get(context.TODO(), key, &client.GetOptions{Sort: sort, Recursive: recursive})
|
||||
if err != nil {
|
||||
handleError(ExitServerError, err)
|
||||
|
@ -51,7 +51,6 @@ func mkCommandFunc(c *cli.Context, ki client.KeysAPI) {
|
||||
|
||||
ttl := c.Int("ttl")
|
||||
|
||||
// TODO: handle transport timeout
|
||||
resp, err := ki.Set(context.TODO(), key, value, &client.SetOptions{TTL: time.Duration(ttl) * time.Second, PrevExist: client.PrevIgnore})
|
||||
if err != nil {
|
||||
handleError(ExitServerError, err)
|
||||
|
@ -46,7 +46,6 @@ func mkdirCommandFunc(c *cli.Context, ki client.KeysAPI, prevExist client.PrevEx
|
||||
key := c.Args()[0]
|
||||
ttl := c.Int("ttl")
|
||||
|
||||
// TODO: handle transport timeout
|
||||
_, err := ki.Set(context.TODO(), key, "", &client.SetOptions{TTL: time.Duration(ttl) * time.Second, Dir: true, PrevExist: prevExist})
|
||||
if err != nil {
|
||||
handleError(ExitServerError, err)
|
||||
|
@ -50,7 +50,6 @@ func rmCommandFunc(c *cli.Context, ki client.KeysAPI) {
|
||||
prevValue := c.String("with-value")
|
||||
prevIndex := c.Int("with-index")
|
||||
|
||||
// TODO: handle transport timeout
|
||||
resp, err := ki.Delete(context.TODO(), key, &client.DeleteOptions{PrevIndex: uint64(prevIndex), PrevValue: prevValue, Dir: dir, Recursive: recursive})
|
||||
if err != nil {
|
||||
handleError(ExitServerError, err)
|
||||
|
@ -40,7 +40,6 @@ func rmdirCommandFunc(c *cli.Context, ki client.KeysAPI) {
|
||||
}
|
||||
key := c.Args()[0]
|
||||
|
||||
// TODO: handle transport timeout
|
||||
resp, err := ki.Delete(context.TODO(), key, &client.DeleteOptions{Dir: true})
|
||||
if err != nil {
|
||||
handleError(ExitServerError, err)
|
||||
|
@ -55,7 +55,6 @@ func setCommandFunc(c *cli.Context, ki client.KeysAPI) {
|
||||
prevValue := c.String("swap-with-value")
|
||||
prevIndex := c.Int("swap-with-index")
|
||||
|
||||
// TODO: handle transport timeout
|
||||
resp, err := ki.Set(context.TODO(), key, value, &client.SetOptions{TTL: time.Duration(ttl) * time.Second, PrevIndex: uint64(prevIndex), PrevValue: prevValue})
|
||||
if err != nil {
|
||||
handleError(ExitServerError, err)
|
||||
|
@ -51,7 +51,6 @@ func updateCommandFunc(c *cli.Context, ki client.KeysAPI) {
|
||||
|
||||
ttl := c.Int("ttl")
|
||||
|
||||
// TODO: handle transport timeout
|
||||
resp, err := ki.Set(context.TODO(), key, value, &client.SetOptions{TTL: time.Duration(ttl) * time.Second, PrevExist: client.PrevExist})
|
||||
if err != nil {
|
||||
handleError(ExitServerError, err)
|
||||
|
@ -51,7 +51,6 @@ func updatedirCommandFunc(c *cli.Context, ki client.KeysAPI) {
|
||||
|
||||
ttl := c.Int("ttl")
|
||||
|
||||
// TODO: handle transport timeout
|
||||
_, err = ki.Set(context.TODO(), key, value, &client.SetOptions{TTL: time.Duration(ttl) * time.Second, Dir: true, PrevExist: client.PrevExist})
|
||||
if err != nil {
|
||||
handleError(ExitServerError, err)
|
||||
|
@ -188,8 +188,9 @@ func mustNewClient(c *cli.Context) client.Client {
|
||||
}
|
||||
|
||||
cfg := client.Config{
|
||||
Transport: tr,
|
||||
Endpoints: eps,
|
||||
Transport: tr,
|
||||
Endpoints: eps,
|
||||
HeaderTimeoutPerRequest: c.GlobalDuration("timeout"),
|
||||
}
|
||||
|
||||
uFlag := c.GlobalString("username")
|
||||
|
@ -16,6 +16,7 @@ package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/codegangsta/cli"
|
||||
"github.com/coreos/etcd/etcdctl/command"
|
||||
@ -37,6 +38,7 @@ func main() {
|
||||
cli.StringFlag{Name: "key-file", Value: "", Usage: "identify HTTPS client using this SSL key file"},
|
||||
cli.StringFlag{Name: "ca-file", Value: "", Usage: "verify certificates of HTTPS-enabled servers using this CA bundle"},
|
||||
cli.StringFlag{Name: "username, u", Value: "", Usage: "provide username[:password] and prompt if password is not supplied."},
|
||||
cli.DurationFlag{Name: "timeout", Value: time.Second, Usage: "connection timeout per request"},
|
||||
}
|
||||
app.Commands = []cli.Command{
|
||||
command.NewBackupCommand(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user