本文整理汇总了Golang中github.com/coreos/etcd/etcdserver/etcdserverpb.KVClient.Range方法的典型用法代码示例。如果您正苦于以下问题:Golang KVClient.Range方法的具体用法?Golang KVClient.Range怎么用?Golang KVClient.Range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coreos/etcd/etcdserver/etcdserverpb.KVClient
的用法示例。
在下文中一共展示了KVClient.Range方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: newStressRange
func newStressRange(kvc pb.KVClient, keySuffixRange int) stressFunc {
return func(ctx context.Context) (error, int64) {
_, err := kvc.Range(ctx, &pb.RangeRequest{
Key: []byte(fmt.Sprintf("foo%016x", rand.Intn(keySuffixRange))),
}, grpc.FailFast(false))
return err, 0
}
}
示例2: newStressRangePrefix
func newStressRangePrefix(kvc pb.KVClient, keySuffixRange int) stressFunc {
return func(ctx context.Context) error {
_, err := kvc.Range(ctx, &pb.RangeRequest{
Key: []byte("foo"),
RangeEnd: []byte(fmt.Sprintf("foo%d", rand.Intn(keySuffixRange))),
}, grpc.FailFast(false))
return err
}
}
示例3: newStressRangeInterval
func newStressRangeInterval(kvc pb.KVClient, keySuffixRange int) stressFunc {
return func(ctx context.Context) (error, int64) {
start := rand.Intn(keySuffixRange)
end := start + 500
_, err := kvc.Range(ctx, &pb.RangeRequest{
Key: []byte(fmt.Sprintf("foo%016x", start)),
RangeEnd: []byte(fmt.Sprintf("foo%016x", end)),
}, grpc.FailFast(false))
return err, 0
}
}
示例4: doRange
func doRange(client etcdserverpb.KVClient, requests <-chan etcdserverpb.RangeRequest) {
defer wg.Done()
for req := 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.Since(st)}
bar.Increment()
}
}
示例5: get
func get(client etcdserverpb.KVClient, 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()
}
}
示例6: waitForRestart
// waitForRestart tries a range request until the client's server responds.
// This is mainly a stop-gap function until grpcproxy's KVClient adapter
// (and by extension, clientv3) supports grpc.CallOption pass-through so
// FailFast=false works with Put.
func waitForRestart(t *testing.T, kvc pb.KVClient) {
req := &pb.RangeRequest{Key: []byte("_"), Serializable: true}
if _, err := kvc.Range(context.TODO(), req, grpc.FailFast(false)); err != nil {
t.Fatal(err)
}
}