OSDN Git Service

Merge pull request #201 from Bytom/v0.1
[bytom/vapor.git] / vendor / github.com / hashicorp / go-plugin / examples / grpc / shared / grpc.go
diff --git a/vendor/github.com/hashicorp/go-plugin/examples/grpc/shared/grpc.go b/vendor/github.com/hashicorp/go-plugin/examples/grpc/shared/grpc.go
deleted file mode 100644 (file)
index 4b532e8..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-package shared
-
-import (
-       "github.com/hashicorp/go-plugin/examples/grpc/proto"
-       "golang.org/x/net/context"
-)
-
-// GRPCClient is an implementation of KV that talks over RPC.
-type GRPCClient struct{ client proto.KVClient }
-
-func (m *GRPCClient) Put(key string, value []byte) error {
-       _, err := m.client.Put(context.Background(), &proto.PutRequest{
-               Key:   key,
-               Value: value,
-       })
-       return err
-}
-
-func (m *GRPCClient) Get(key string) ([]byte, error) {
-       resp, err := m.client.Get(context.Background(), &proto.GetRequest{
-               Key: key,
-       })
-       if err != nil {
-               return nil, err
-       }
-
-       return resp.Value, nil
-}
-
-// Here is the gRPC server that GRPCClient talks to.
-type GRPCServer struct {
-       // This is the real implementation
-       Impl KV
-}
-
-func (m *GRPCServer) Put(
-       ctx context.Context,
-       req *proto.PutRequest) (*proto.Empty, error) {
-       return &proto.Empty{}, m.Impl.Put(req.Key, req.Value)
-}
-
-func (m *GRPCServer) Get(
-       ctx context.Context,
-       req *proto.GetRequest) (*proto.GetResponse, error) {
-       v, err := m.Impl.Get(req.Key)
-       return &proto.GetResponse{Value: v}, err
-}