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 15package adapter 16 17import ( 18 "context" 19 20 pb "github.com/coreos/etcd/etcdserver/etcdserverpb" 21 22 grpc "google.golang.org/grpc" 23) 24 25type kvs2kvc struct{ kvs pb.KVServer } 26 27func KvServerToKvClient(kvs pb.KVServer) pb.KVClient { 28 return &kvs2kvc{kvs} 29} 30 31func (s *kvs2kvc) Range(ctx context.Context, in *pb.RangeRequest, opts ...grpc.CallOption) (*pb.RangeResponse, error) { 32 return s.kvs.Range(ctx, in) 33} 34 35func (s *kvs2kvc) Put(ctx context.Context, in *pb.PutRequest, opts ...grpc.CallOption) (*pb.PutResponse, error) { 36 return s.kvs.Put(ctx, in) 37} 38 39func (s *kvs2kvc) DeleteRange(ctx context.Context, in *pb.DeleteRangeRequest, opts ...grpc.CallOption) (*pb.DeleteRangeResponse, error) { 40 return s.kvs.DeleteRange(ctx, in) 41} 42 43func (s *kvs2kvc) Txn(ctx context.Context, in *pb.TxnRequest, opts ...grpc.CallOption) (*pb.TxnResponse, error) { 44 return s.kvs.Txn(ctx, in) 45} 46 47func (s *kvs2kvc) Compact(ctx context.Context, in *pb.CompactionRequest, opts ...grpc.CallOption) (*pb.CompactionResponse, error) { 48 return s.kvs.Compact(ctx, in) 49} 50