khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 1 | // Copyright 2016 The etcd Authors |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package adapter |
| 16 | |
| 17 | import ( |
| 18 | "context" |
| 19 | |
| 20 | pb "go.etcd.io/etcd/etcdserver/etcdserverpb" |
| 21 | |
| 22 | grpc "google.golang.org/grpc" |
| 23 | ) |
| 24 | |
| 25 | type kvs2kvc struct{ kvs pb.KVServer } |
| 26 | |
| 27 | func KvServerToKvClient(kvs pb.KVServer) pb.KVClient { |
| 28 | return &kvs2kvc{kvs} |
| 29 | } |
| 30 | |
| 31 | func (s *kvs2kvc) Range(ctx context.Context, in *pb.RangeRequest, opts ...grpc.CallOption) (*pb.RangeResponse, error) { |
| 32 | return s.kvs.Range(ctx, in) |
| 33 | } |
| 34 | |
| 35 | func (s *kvs2kvc) Put(ctx context.Context, in *pb.PutRequest, opts ...grpc.CallOption) (*pb.PutResponse, error) { |
| 36 | return s.kvs.Put(ctx, in) |
| 37 | } |
| 38 | |
| 39 | func (s *kvs2kvc) DeleteRange(ctx context.Context, in *pb.DeleteRangeRequest, opts ...grpc.CallOption) (*pb.DeleteRangeResponse, error) { |
| 40 | return s.kvs.DeleteRange(ctx, in) |
| 41 | } |
| 42 | |
| 43 | func (s *kvs2kvc) Txn(ctx context.Context, in *pb.TxnRequest, opts ...grpc.CallOption) (*pb.TxnResponse, error) { |
| 44 | return s.kvs.Txn(ctx, in) |
| 45 | } |
| 46 | |
| 47 | func (s *kvs2kvc) Compact(ctx context.Context, in *pb.CompactionRequest, opts ...grpc.CallOption) (*pb.CompactionResponse, error) { |
| 48 | return s.kvs.Compact(ctx, in) |
| 49 | } |