mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcd-runner: Added client connection timeout flag
This commit is contained in:
parent
ddc94aaf9e
commit
6e7e346c93
@ -33,6 +33,8 @@ import (
|
|||||||
"github.com/coreos/etcd/clientv3/concurrency"
|
"github.com/coreos/etcd/clientv3/concurrency"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var clientTimeout int64
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rand.Seed(time.Now().UTC().UnixNano())
|
rand.Seed(time.Now().UTC().UnixNano())
|
||||||
}
|
}
|
||||||
@ -43,6 +45,7 @@ func main() {
|
|||||||
endpointStr := flag.String("endpoints", "localhost:2379", "endpoints of etcd cluster")
|
endpointStr := flag.String("endpoints", "localhost:2379", "endpoints of etcd cluster")
|
||||||
mode := flag.String("mode", "watcher", "test mode (election, lock-racer, lease-renewer, watcher)")
|
mode := flag.String("mode", "watcher", "test mode (election, lock-racer, lease-renewer, watcher)")
|
||||||
round := flag.Int("rounds", 100, "number of rounds to run")
|
round := flag.Int("rounds", 100, "number of rounds to run")
|
||||||
|
flag.Int64Var(&clientTimeout, "client-timeout", 60, "max timeout seconds for a client to get connection")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
eps := strings.Split(*endpointStr, ",")
|
eps := strings.Split(*endpointStr, ",")
|
||||||
|
|
||||||
@ -405,7 +408,7 @@ func generateRandomKey(strlen uint) string {
|
|||||||
func newClient(eps []string) *clientv3.Client {
|
func newClient(eps []string) *clientv3.Client {
|
||||||
c, err := clientv3.New(clientv3.Config{
|
c, err := clientv3.New(clientv3.Config{
|
||||||
Endpoints: eps,
|
Endpoints: eps,
|
||||||
DialTimeout: 5 * time.Second,
|
DialTimeout: time.Duration(clientTimeout) * time.Second,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user