mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
feat(etcdbench): Add -endpoint flag to etcdbench
This commit is contained in:
parent
000290dc94
commit
471c40735c
@ -8,8 +8,8 @@ import (
|
||||
"github.com/coreos/go-etcd/etcd"
|
||||
)
|
||||
|
||||
func write(requests int, end chan int) {
|
||||
client := etcd.NewClient(nil)
|
||||
func write(endpoint string, requests int, end chan int) {
|
||||
client := etcd.NewClient([]string{endpoint})
|
||||
|
||||
for i := 0; i < requests; i++ {
|
||||
key := strconv.Itoa(i)
|
||||
@ -18,8 +18,8 @@ func write(requests int, end chan int) {
|
||||
end <- 1
|
||||
}
|
||||
|
||||
func watch(key string) {
|
||||
client := etcd.NewClient(nil)
|
||||
func watch(endpoint string, key string) {
|
||||
client := etcd.NewClient([]string{endpoint})
|
||||
|
||||
receiver := make(chan *etcd.Response)
|
||||
go client.Watch(key, 0, true, receiver, nil)
|
||||
@ -34,6 +34,8 @@ func watch(key string) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
endpoint := flag.String("endpoint", "http://127.0.0.1:4001/", "etcd HTTP endpoint")
|
||||
|
||||
rWrites := flag.Int("write-requests", 50000, "number of writes")
|
||||
cWrites := flag.Int("concurrent-writes", 500, "number of concurrent writes")
|
||||
|
||||
@ -43,12 +45,12 @@ func main() {
|
||||
|
||||
for i := 0; i < *watches; i++ {
|
||||
key := strconv.Itoa(i)
|
||||
go watch(key)
|
||||
go watch(*endpoint, key)
|
||||
}
|
||||
|
||||
wChan := make(chan int, *cWrites)
|
||||
for i := 0; i < *cWrites; i++ {
|
||||
go write((*rWrites / *cWrites), wChan)
|
||||
go write(*endpoint, (*rWrites / *cWrites), wChan)
|
||||
}
|
||||
|
||||
for i := 0; i < *cWrites; i++ {
|
||||
|
Loading…
x
Reference in New Issue
Block a user