key.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2015 CoreOS, Inc.
  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. package v3rpc
  15. import (
  16. "github.com/coreos/etcd/Godeps/_workspace/src/golang.org/x/net/context"
  17. "github.com/coreos/etcd/etcdserver"
  18. pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
  19. )
  20. type handler struct {
  21. server etcdserver.V3DemoServer
  22. }
  23. func New(s etcdserver.V3DemoServer) pb.EtcdServer {
  24. return &handler{s}
  25. }
  26. func (h *handler) Range(ctx context.Context, r *pb.RangeRequest) (*pb.RangeResponse, error) {
  27. resp := h.server.V3DemoDo(ctx, pb.InternalRaftRequest{Range: r})
  28. return resp.(*pb.RangeResponse), nil
  29. }
  30. func (h *handler) Put(ctx context.Context, r *pb.PutRequest) (*pb.PutResponse, error) {
  31. resp := h.server.V3DemoDo(ctx, pb.InternalRaftRequest{Put: r})
  32. return resp.(*pb.PutResponse), nil
  33. }
  34. func (h *handler) DeleteRange(ctx context.Context, r *pb.DeleteRangeRequest) (*pb.DeleteRangeResponse, error) {
  35. resp := h.server.V3DemoDo(ctx, pb.InternalRaftRequest{DeleteRange: r})
  36. return resp.(*pb.DeleteRangeResponse), nil
  37. }
  38. func (h *handler) Txn(ctx context.Context, r *pb.TxnRequest) (*pb.TxnResponse, error) {
  39. panic("not implemented")
  40. return nil, nil
  41. }
  42. func (h *handler) Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error) {
  43. panic("not implemented")
  44. return nil, nil
  45. }