Exemple #1
0
func put(client etcdserverpb.EtcdClient, requests <-chan *etcdserverpb.PutRequest) {
	defer wg.Done()

	for r := range requests {
		st := time.Now()
		_, err := client.Put(context.Background(), r)

		var errStr string
		if err != nil {
			errStr = err.Error()
		}
		results <- &result{
			errStr:   errStr,
			duration: time.Now().Sub(st),
		}
		bar.Increment()
	}
}
Exemple #2
0
func get(client etcdserverpb.EtcdClient, key, end []byte, requests <-chan struct{}) {
	defer wg.Done()
	req := &etcdserverpb.RangeRequest{Key: key, RangeEnd: end}

	for _ = range requests {
		st := time.Now()
		_, err := client.Range(context.Background(), req)

		var errStr string
		if err != nil {
			errStr = err.Error()
		}
		results <- &result{
			errStr:   errStr,
			duration: time.Now().Sub(st),
		}
		bar.Increment()
	}
}