本文整理匯總了Golang中github.com/coreos/etcd/etcdserver/etcdserverpb.KVClient.DeleteRange方法的典型用法代碼示例。如果您正苦於以下問題:Golang KVClient.DeleteRange方法的具體用法?Golang KVClient.DeleteRange怎麽用?Golang KVClient.DeleteRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/coreos/etcd/etcdserver/etcdserverpb.KVClient
的用法示例。
在下文中一共展示了KVClient.DeleteRange方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: deletePrefix
// deletePrefix performs a RangeRequest to get keys on a given prefix
func deletePrefix(kv pb.KVClient, prefix string) (*pb.DeleteRangeResponse, error) {
return kv.DeleteRange(
context.TODO(),
&pb.DeleteRangeRequest{
Key: []byte(prefix),
RangeEnd: []byte(prefixEnd(prefix))})
}
示例2: newStressDelete
func newStressDelete(kvc pb.KVClient, keySuffixRange int) stressFunc {
return func(ctx context.Context) (error, int64) {
_, err := kvc.DeleteRange(ctx, &pb.DeleteRangeRequest{
Key: []byte(fmt.Sprintf("foo%016x", rand.Intn(keySuffixRange))),
}, grpc.FailFast(false))
return err, 1
}
}
示例3: newStressDeletePrefix
func newStressDeletePrefix(kvc pb.KVClient, keySuffixRange int) stressFunc {
return func(ctx context.Context) error {
_, err := kvc.DeleteRange(ctx, &pb.DeleteRangeRequest{
Key: []byte("foo"),
RangeEnd: []byte(fmt.Sprintf("foo%d", rand.Intn(keySuffixRange))),
}, grpc.FailFast(false))
return err
}
}
示例4: newStressDeleteInterval
func newStressDeleteInterval(kvc pb.KVClient, keySuffixRange int) stressFunc {
return func(ctx context.Context) error {
start := rand.Intn(keySuffixRange)
end := start + 500
_, err := kvc.DeleteRange(ctx, &pb.DeleteRangeRequest{
Key: []byte(fmt.Sprintf("foo%016x", start)),
RangeEnd: []byte(fmt.Sprintf("foo%016x", end)),
}, grpc.FailFast(false))
return err
}
}