예제 #1
0
파일: put.go 프로젝트: carriercomm/etcd
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()
	}
}
예제 #2
0
파일: get.go 프로젝트: BlueStalker/etcd
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()
	}
}