From 015759f660f39bc7af9cfa7699701d27d3223a6c Mon Sep 17 00:00:00 2001 From: Minoru Osuka Date: Thu, 19 Mar 2020 17:00:26 +0900 Subject: [PATCH] Add join endpoint --- README.md | 30 ++++++ kvs/marshaler.go | 15 +++ protobuf/kvs/kvs.pb.go | 203 +++++++++++++++++++------------------- protobuf/kvs/kvs.pb.gw.go | 178 +++++++++++++++++++++++++++------ protobuf/kvs/kvs.proto | 15 ++- 5 files changed, 303 insertions(+), 138 deletions(-) diff --git a/README.md b/README.md index ad002c3..1072056 100644 --- a/README.md +++ b/README.md @@ -223,6 +223,36 @@ You can see the result in JSON format. The result of the above command is: Recommend 3 or more odd number of nodes in the cluster. In failure scenarios, data loss is inevitable, so avoid deploying single nodes. +The above example, the node joins to the cluster at startup, but you can also join the node that already started on standalone mode to the cluster later, as follows: + +```bash +$ ./bin/cete join --grpc-addr=:9000 node2 127.0.0.1:9001 +``` + +or, you can use the RESTful API as follows: + +```bash +$ curl -X PUT 'http://127.0.0.1:8000/v1/cluster/node2' --data-binary ' +{ + "bind_addr": ":7001", + "grpc_addr": ":9001", + "http_addr": ":8001" +} +' +``` + +To remove a node from the cluster, execute the following command: + +```bash +$ ./bin/cete leave --grpc-addr=:9000 node2 +``` + +or, you can use the RESTful API as follows: + +```bash +$ curl -X DELETE 'http://127.0.0.1:8000/v1/cluster/node2' +``` + The following command indexes documents to any node in the cluster: ```bash diff --git a/kvs/marshaler.go b/kvs/marshaler.go index e9793a6..c4a2547 100644 --- a/kvs/marshaler.go +++ b/kvs/marshaler.go @@ -62,6 +62,21 @@ func (j *CeteMarshaler) NewDecoder(r io.Reader) runtime.Decoder { case *pbkvs.PutRequest: v.(*pbkvs.PutRequest).Value = buffer return nil + case *pbkvs.JoinRequest: + var tmpValue map[string]interface{} + if err = json.Unmarshal(buffer, &tmpValue); err != nil { + return err + } + if bindAddr, ok := tmpValue["bind_addr"].(string); ok { + v.(*pbkvs.JoinRequest).BindAddr = bindAddr + } + if grpcAddr, ok := tmpValue["grpc_addr"].(string); ok { + v.(*pbkvs.JoinRequest).GrpcAddr = grpcAddr + } + if httpAddr, ok := tmpValue["http_addr"].(string); ok { + v.(*pbkvs.JoinRequest).HttpAddr = httpAddr + } + return nil default: return json.Unmarshal(buffer, v) } diff --git a/protobuf/kvs/kvs.pb.go b/protobuf/kvs/kvs.pb.go index 2ad453f..eaa8617 100644 --- a/protobuf/kvs/kvs.pb.go +++ b/protobuf/kvs/kvs.pb.go @@ -705,59 +705,60 @@ func init() { func init() { proto.RegisterFile("protobuf/kvs/kvs.proto", fileDescriptor_6e9909cfc2f34163) } var fileDescriptor_6e9909cfc2f34163 = []byte{ - // 828 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xdb, 0x8e, 0xda, 0x56, - 0x14, 0x1d, 0xdf, 0x66, 0x60, 0x03, 0xc1, 0x73, 0x42, 0x47, 0xc4, 0x49, 0x93, 0xd4, 0x51, 0xa5, - 0x11, 0xed, 0xd8, 0x2d, 0xbd, 0x2a, 0x6a, 0x2a, 0x4d, 0x89, 0x15, 0x25, 0x50, 0x06, 0x31, 0x13, - 0x22, 0xf5, 0xa5, 0x3a, 0xe0, 0x53, 0xb0, 0x00, 0xdb, 0xb5, 0x8f, 0xa9, 0xac, 0x28, 0x2f, 0x7d, - 0xef, 0x53, 0x3f, 0xa0, 0xcf, 0xfd, 0x8b, 0xfe, 0x43, 0x7f, 0xa1, 0x1f, 0x52, 0x9d, 0xe3, 0x63, - 0x2e, 0x43, 0x3c, 0xbd, 0x3c, 0x20, 0xf0, 0x5e, 0x6b, 0xaf, 0xbd, 0xce, 0x65, 0x19, 0x38, 0x09, - 0xa3, 0x80, 0x06, 0xe3, 0xe4, 0x07, 0x7b, 0xbe, 0x8a, 0xd9, 0xc7, 0xe2, 0x05, 0xa4, 0xcc, 0x57, - 0xb1, 0x71, 0x67, 0x1a, 0x04, 0xd3, 0x05, 0xb1, 0xd7, 0x1c, 0xec, 0xa7, 0x19, 0x6e, 0xdc, 0xbd, - 0x0e, 0x91, 0x65, 0x48, 0x73, 0xf0, 0x9e, 0x00, 0x71, 0xe8, 0xd9, 0xd8, 0xf7, 0x03, 0x8a, 0xa9, - 0x17, 0xf8, 0x42, 0xda, 0xf8, 0x90, 0x7f, 0x4d, 0xce, 0xa6, 0xc4, 0x3f, 0x8b, 0x7f, 0xc2, 0xd3, - 0x29, 0x89, 0xec, 0x20, 0xe4, 0x8c, 0x7d, 0xb6, 0x19, 0x83, 0xda, 0x0f, 0x5c, 0x82, 0xee, 0x42, - 0x79, 0xec, 0xf9, 0xee, 0xf7, 0xd8, 0x75, 0xa3, 0xa6, 0xf4, 0x50, 0x3a, 0x2d, 0x0f, 0x4b, 0xac, - 0x70, 0xee, 0xba, 0x11, 0x03, 0xa7, 0x51, 0x38, 0xc9, 0x40, 0x39, 0x03, 0x59, 0x21, 0x07, 0x67, - 0x94, 0x86, 0x19, 0xa8, 0x64, 0x20, 0x2b, 0x70, 0xb0, 0x01, 0x5a, 0x4c, 0x31, 0x25, 0x4d, 0x95, - 0x03, 0xd9, 0x83, 0x49, 0xa1, 0xf2, 0x22, 0xf0, 0xfc, 0x21, 0xf9, 0x31, 0x21, 0x31, 0x45, 0xb7, - 0x40, 0xf6, 0x5c, 0x31, 0x54, 0xf6, 0xdc, 0x5d, 0x2f, 0xf2, 0x4d, 0x5e, 0x94, 0x9b, 0xbc, 0xa8, - 0xbb, 0x5e, 0xcc, 0xfb, 0x50, 0xed, 0x11, 0xbc, 0x22, 0x05, 0x63, 0xcd, 0x33, 0xa8, 0xb2, 0xad, - 0x18, 0x92, 0x38, 0x0c, 0xfc, 0x98, 0xa0, 0x77, 0x41, 0xf5, 0x03, 0x97, 0x70, 0x46, 0xa5, 0x5d, - 0xb6, 0xd8, 0xe9, 0x71, 0x02, 0x2f, 0x9b, 0xbf, 0x48, 0x50, 0xef, 0x2c, 0x92, 0x98, 0x92,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 0x49, 0x4d, 0x84, 0xc4, 0x57, - 0x50, 0xba, 0xf4, 0x71, 0x18, 0xcf, 0x02, 0x5a, 0x28, 0x57, 0xbc, 0x37, 0x1d, 0x50, 0x9e, 0x11, - 0x8a, 0xea, 0x7c, 0xde, 0x26, 0xb2, 0x86, 0xbe, 0x29, 0x88, 0xe1, 0x77, 0xf8, 0xf0, 0xdb, 0xe8, - 0x98, 0x0d, 0x67, 0x17, 0xc7, 0x7e, 0x3d, 0x27, 0xe9, 0x93, 0x56, 0xeb, 0x0d, 0xea, 0x81, 0x32, - 0x48, 0x72, 0x91, 0x4d, 0x64, 0x0b, 0xc7, 0xde, 0xe3, 0x52, 0x27, 0xc6, 0xbe, 0xd4, 0x63, 0xa9, - 0x85, 0x2e, 0xe0, 0x30, 0x0b, 0x30, 0x42, 0x5c, 0x70, 0x27, 0xcd, 0x85, 0x9a, 0xc2, 0x5e, 0xeb, - 0x2d, 0xf6, 0xbe, 0x00, 0x8d, 0x07, 0xa5, 0x70, 0x7b, 0xd0, 0x7e, 0x98, 0xcc, 0x83, 0x8f, 0x24, - 0x76, 0x50, 0xe2, 0x66, 0xff, 0xc3, 0x41, 0x5d, 0xbb, 0xff, 0xbb, 0x07, 0x25, 0xae, 0xfe, 0x37, - 0xef, 0x7f, 0xf7, 0x68, 0xea, 0xd1, 0x59, 0x32, 0xb6, 0x26, 0xc1, 0xd2, 0x5e, 0x06, 0x71, 0x32, - 0xc7, 0xf6, 0x84, 0xd0, 0xad, 0x3f, 0xd6, 0xf9, 0x2a, 0x1e, 0x1f, 0xf2, 0xa7, 0x4f, 0xfe, 0x0e, - 0x00, 0x00, 0xff, 0xff, 0x79, 0x13, 0xd7, 0xf7, 0xae, 0x07, 0x00, 0x00, + // 845 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xcb, 0x6e, 0xdb, 0x46, + 0x14, 0x0d, 0x5f, 0x7e, 0x5c, 0xc9, 0x36, 0x33, 0x51, 0x0d, 0x85, 0x4e, 0x93, 0x94, 0x41, 0x01, + 0x43, 0xad, 0xc9, 0x56, 0x7d, 0x22, 0x40, 0x0a, 0xb8, 0x0a, 0x11, 0x34, 0x52, 0x64, 0x41, 0x76, + 0x14, 0xa0, 0x9b, 0x62, 0x24, 0x4e, 0x25, 0x42, 0x12, 0xc9, 0x72, 0x86, 0x2a, 0x88, 0x20, 0x9b, + 0xee, 0xbb, 0xea, 0x07, 0x74, 0xdd, 0xef, 0xe9, 0x2f, 0xf4, 0x0b, 0xfa, 0x05, 0xc5, 0x0c, 0x87, + 0x7a, 0x58, 0xa1, 0xdb, 0x66, 0x61, 0xd8, 0xbc, 0xe7, 0xdc, 0x33, 0x67, 0x66, 0xee, 0x19, 0xc3, + 0x71, 0x9c, 0x44, 0x2c, 0x1a, 0xa6, 0x3f, 0xba, 0xd3, 0x05, 0xe5, 0x3f, 0x8e, 0x28, 0x20, 0x6d, + 0xba, 0xa0, 0xd6, 0xdd, 0x71, 0x14, 0x8d, 0x67, 0xc4, 0x5d, 0x72, 0x70, 0x98, 0xe5, 0xb8, 0x75, + 0x72, 0x1d, 0x22, 0xf3, 0x98, 0x15, 0xe0, 0x3d, 0x09, 0xe2, 0x38, 0x70, 0x71, 0x18, 0x46, 0x0c, + 0xb3, 0x20, 0x0a, 0xa5, 0xb4, 0xf5, 0xb1, 0xf8, 0x35, 0x3a, 0x1b, 0x93, 0xf0, 0x8c, 0xfe, 0x8c, + 0xc7, 0x63, 0x92, 0xb8, 0x51, 0x2c, 0x18, 0xdb, 0x6c, 0x9b, 0x82, 0xde, 0x8d, 0x7c, 0x82, 0x4e, + 0x60, 0x7f, 0x18, 0x84, 0xfe, 0x0f, 0xd8, 0xf7, 0x93, 0xba, 0xf2, 0x50, 0x39, 0xdd, 0xef, 0xef, + 0xf1, 0xc2, 0xb9, 0xef, 0x27, 0x1c, 0x1c, 0x27, 0xf1, 0x28, 0x07, 0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xee, 0x09, 0xa9, 0x63, 0x6b, 0x5b, + 0x8a, 0x5f, 0xc0, 0x05, 0xec, 0xe4, 0x91, 0x47, 0x48, 0x08, 0x6e, 0xe4, 0xbf, 0x54, 0x53, 0xda, + 0x6b, 0xbc, 0xc5, 0xde, 0x57, 0x60, 0x88, 0x68, 0x95, 0x1e, 0x19, 0xda, 0x8e, 0x9f, 0x7d, 0xeb, + 0x13, 0x85, 0x8f, 0x82, 0xcc, 0xc2, 0xbf, 0x8c, 0xc2, 0xb5, 0xc4, 0x6c, 0x8e, 0x82, 0x0c, 0xcb, + 0xb7, 0x1f, 0x7e, 0xff, 0x68, 0x1c, 0xb0, 0x49, 0x3a, 0x74, 0x46, 0xd1, 0xdc, 0x9d, 0x47, 0x34, + 0x9d, 0x62, 0x77, 0x44, 0xd8, 0xda, 0xbf, 0xe2, 0xe9, 0x82, 0x0e, 0x77, 0xc4, 0xd7, 0x67, 0xff, + 0x04, 0x00, 0x00, 0xff, 0xff, 0xe3, 0xf6, 0x2a, 0x52, 0xe0, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -772,10 +773,10 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type KVSClient interface { - Join(ctx context.Context, in *JoinRequest, opts ...grpc.CallOption) (*empty.Empty, error) - Leave(ctx context.Context, in *LeaveRequest, opts ...grpc.CallOption) (*empty.Empty, error) Node(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*NodeResponse, error) + Join(ctx context.Context, in *JoinRequest, opts ...grpc.CallOption) (*empty.Empty, error) Cluster(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*ClusterResponse, error) + Leave(ctx context.Context, in *LeaveRequest, opts ...grpc.CallOption) (*empty.Empty, error) Snapshot(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*empty.Empty, error) Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*empty.Empty, error) @@ -792,36 +793,36 @@ func NewKVSClient(cc *grpc.ClientConn) KVSClient { return &kVSClient{cc} } -func (c *kVSClient) Join(ctx context.Context, in *JoinRequest, opts ...grpc.CallOption) (*empty.Empty, error) { - out := new(empty.Empty) - err := c.cc.Invoke(ctx, "/kvs.KVS/Join", in, out, opts...) +func (c *kVSClient) Node(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*NodeResponse, error) { + out := new(NodeResponse) + err := c.cc.Invoke(ctx, "/kvs.KVS/Node", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *kVSClient) Leave(ctx context.Context, in *LeaveRequest, opts ...grpc.CallOption) (*empty.Empty, error) { +func (c *kVSClient) Join(ctx context.Context, in *JoinRequest, opts ...grpc.CallOption) (*empty.Empty, error) { out := new(empty.Empty) - err := c.cc.Invoke(ctx, "/kvs.KVS/Leave", in, out, opts...) + err := c.cc.Invoke(ctx, "/kvs.KVS/Join", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *kVSClient) Node(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*NodeResponse, error) { - out := new(NodeResponse) - err := c.cc.Invoke(ctx, "/kvs.KVS/Node", in, out, opts...) +func (c *kVSClient) Cluster(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*ClusterResponse, error) { + out := new(ClusterResponse) + err := c.cc.Invoke(ctx, "/kvs.KVS/Cluster", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *kVSClient) Cluster(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*ClusterResponse, error) { - out := new(ClusterResponse) - err := c.cc.Invoke(ctx, "/kvs.KVS/Cluster", in, out, opts...) +func (c *kVSClient) Leave(ctx context.Context, in *LeaveRequest, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) + err := c.cc.Invoke(ctx, "/kvs.KVS/Leave", in, out, opts...) if err != nil { return nil, err } @@ -907,10 +908,10 @@ func (c *kVSClient) Metrics(ctx context.Context, in *empty.Empty, opts ...grpc.C // KVSServer is the server API for KVS service. type KVSServer interface { - Join(context.Context, *JoinRequest) (*empty.Empty, error) - Leave(context.Context, *LeaveRequest) (*empty.Empty, error) Node(context.Context, *empty.Empty) (*NodeResponse, error) + Join(context.Context, *JoinRequest) (*empty.Empty, error) Cluster(context.Context, *empty.Empty) (*ClusterResponse, error) + Leave(context.Context, *LeaveRequest) (*empty.Empty, error) Snapshot(context.Context, *empty.Empty) (*empty.Empty, error) Get(context.Context, *GetRequest) (*GetResponse, error) Put(context.Context, *PutRequest) (*empty.Empty, error) @@ -923,18 +924,18 @@ type KVSServer interface { type UnimplementedKVSServer struct { } -func (*UnimplementedKVSServer) Join(ctx context.Context, req *JoinRequest) (*empty.Empty, error) { - return nil, status.Errorf(codes.Unimplemented, "method Join not implemented") -} -func (*UnimplementedKVSServer) Leave(ctx context.Context, req *LeaveRequest) (*empty.Empty, error) { - return nil, status.Errorf(codes.Unimplemented, "method Leave not implemented") -} func (*UnimplementedKVSServer) Node(ctx context.Context, req *empty.Empty) (*NodeResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Node not implemented") } +func (*UnimplementedKVSServer) Join(ctx context.Context, req *JoinRequest) (*empty.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method Join not implemented") +} func (*UnimplementedKVSServer) Cluster(ctx context.Context, req *empty.Empty) (*ClusterResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Cluster not implemented") } +func (*UnimplementedKVSServer) Leave(ctx context.Context, req *LeaveRequest) (*empty.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method Leave not implemented") +} func (*UnimplementedKVSServer) Snapshot(ctx context.Context, req *empty.Empty) (*empty.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method Snapshot not implemented") } @@ -958,74 +959,74 @@ func RegisterKVSServer(s *grpc.Server, srv KVSServer) { s.RegisterService(&_KVS_serviceDesc, srv) } -func _KVS_Join_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(JoinRequest) +func _KVS_Node_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(empty.Empty) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(KVSServer).Join(ctx, in) + return srv.(KVSServer).Node(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kvs.KVS/Join", + FullMethod: "/kvs.KVS/Node", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(KVSServer).Join(ctx, req.(*JoinRequest)) + return srv.(KVSServer).Node(ctx, req.(*empty.Empty)) } return interceptor(ctx, in, info, handler) } -func _KVS_Leave_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(LeaveRequest) +func _KVS_Join_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(JoinRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(KVSServer).Leave(ctx, in) + return srv.(KVSServer).Join(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kvs.KVS/Leave", + FullMethod: "/kvs.KVS/Join", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(KVSServer).Leave(ctx, req.(*LeaveRequest)) + return srv.(KVSServer).Join(ctx, req.(*JoinRequest)) } return interceptor(ctx, in, info, handler) } -func _KVS_Node_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _KVS_Cluster_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(empty.Empty) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(KVSServer).Node(ctx, in) + return srv.(KVSServer).Cluster(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kvs.KVS/Node", + FullMethod: "/kvs.KVS/Cluster", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(KVSServer).Node(ctx, req.(*empty.Empty)) + return srv.(KVSServer).Cluster(ctx, req.(*empty.Empty)) } return interceptor(ctx, in, info, handler) } -func _KVS_Cluster_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(empty.Empty) +func _KVS_Leave_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LeaveRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(KVSServer).Cluster(ctx, in) + return srv.(KVSServer).Leave(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kvs.KVS/Cluster", + FullMethod: "/kvs.KVS/Leave", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(KVSServer).Cluster(ctx, req.(*empty.Empty)) + return srv.(KVSServer).Leave(ctx, req.(*LeaveRequest)) } return interceptor(ctx, in, info, handler) } @@ -1145,22 +1146,22 @@ var _KVS_serviceDesc = grpc.ServiceDesc{ ServiceName: "kvs.KVS", HandlerType: (*KVSServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "Join", - Handler: _KVS_Join_Handler, - }, - { - MethodName: "Leave", - Handler: _KVS_Leave_Handler, - }, { MethodName: "Node", Handler: _KVS_Node_Handler, }, + { + MethodName: "Join", + Handler: _KVS_Join_Handler, + }, { MethodName: "Cluster", Handler: _KVS_Cluster_Handler, }, + { + MethodName: "Leave", + Handler: _KVS_Leave_Handler, + }, { MethodName: "Snapshot", Handler: _KVS_Snapshot_Handler, diff --git a/protobuf/kvs/kvs.pb.gw.go b/protobuf/kvs/kvs.pb.gw.go index 21d085d..d040f44 100644 --- a/protobuf/kvs/kvs.pb.gw.go +++ b/protobuf/kvs/kvs.pb.gw.go @@ -32,10 +32,36 @@ var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage -func request_KVS_Leave_0(ctx context.Context, marshaler runtime.Marshaler, client KVSClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq LeaveRequest +func request_KVS_Node_0(ctx context.Context, marshaler runtime.Marshaler, client KVSClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq empty.Empty var metadata runtime.ServerMetadata + msg, err := client.Node(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_KVS_Node_0(ctx context.Context, marshaler runtime.Marshaler, server KVSServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq empty.Empty + var metadata runtime.ServerMetadata + + msg, err := server.Node(ctx, &protoReq) + return msg, metadata, err + +} + +func request_KVS_Join_0(ctx context.Context, marshaler runtime.Marshaler, client KVSClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq JoinRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + var ( val string ok bool @@ -54,15 +80,23 @@ func request_KVS_Leave_0(ctx context.Context, marshaler runtime.Marshaler, clien return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } - msg, err := client.Leave(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.Join(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_KVS_Leave_0(ctx context.Context, marshaler runtime.Marshaler, server KVSServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq LeaveRequest +func local_request_KVS_Join_0(ctx context.Context, marshaler runtime.Marshaler, server KVSServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq JoinRequest var metadata runtime.ServerMetadata + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + var ( val string ok bool @@ -81,43 +115,79 @@ func local_request_KVS_Leave_0(ctx context.Context, marshaler runtime.Marshaler, return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } - msg, err := server.Leave(ctx, &protoReq) + msg, err := server.Join(ctx, &protoReq) return msg, metadata, err } -func request_KVS_Node_0(ctx context.Context, marshaler runtime.Marshaler, client KVSClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_KVS_Cluster_0(ctx context.Context, marshaler runtime.Marshaler, client KVSClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq empty.Empty var metadata runtime.ServerMetadata - msg, err := client.Node(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.Cluster(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_KVS_Node_0(ctx context.Context, marshaler runtime.Marshaler, server KVSServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_KVS_Cluster_0(ctx context.Context, marshaler runtime.Marshaler, server KVSServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq empty.Empty var metadata runtime.ServerMetadata - msg, err := server.Node(ctx, &protoReq) + msg, err := server.Cluster(ctx, &protoReq) return msg, metadata, err } -func request_KVS_Cluster_0(ctx context.Context, marshaler runtime.Marshaler, client KVSClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq empty.Empty +func request_KVS_Leave_0(ctx context.Context, marshaler runtime.Marshaler, client KVSClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq LeaveRequest var metadata runtime.ServerMetadata - msg, err := client.Cluster(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.Leave(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_KVS_Cluster_0(ctx context.Context, marshaler runtime.Marshaler, server KVSServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq empty.Empty +func local_request_KVS_Leave_0(ctx context.Context, marshaler runtime.Marshaler, server KVSServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq LeaveRequest var metadata runtime.ServerMetadata - msg, err := server.Cluster(ctx, &protoReq) + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.Leave(ctx, &protoReq) return msg, metadata, err } @@ -341,7 +411,7 @@ func local_request_KVS_Metrics_0(ctx context.Context, marshaler runtime.Marshale // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. func RegisterKVSHandlerServer(ctx context.Context, mux *runtime.ServeMux, server KVSServer) error { - mux.Handle("DELETE", pattern_KVS_Leave_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_KVS_Node_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -350,18 +420,18 @@ func RegisterKVSHandlerServer(ctx context.Context, mux *runtime.ServeMux, server runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_KVS_Leave_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_KVS_Node_0(rctx, inboundMarshaler, server, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_KVS_Leave_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_KVS_Node_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_KVS_Node_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("PUT", pattern_KVS_Join_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -370,14 +440,14 @@ func RegisterKVSHandlerServer(ctx context.Context, mux *runtime.ServeMux, server runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_KVS_Node_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_KVS_Join_0(rctx, inboundMarshaler, server, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_KVS_Node_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_KVS_Join_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -401,6 +471,26 @@ func RegisterKVSHandlerServer(ctx context.Context, mux *runtime.ServeMux, server }) + mux.Handle("DELETE", pattern_KVS_Leave_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_KVS_Leave_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_KVS_Leave_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_KVS_Snapshot_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -542,7 +632,7 @@ func RegisterKVSHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.C // "KVSClient" to call the correct interceptors. func RegisterKVSHandlerClient(ctx context.Context, mux *runtime.ServeMux, client KVSClient) error { - mux.Handle("DELETE", pattern_KVS_Leave_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_KVS_Node_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -551,18 +641,18 @@ func RegisterKVSHandlerClient(ctx context.Context, mux *runtime.ServeMux, client runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_KVS_Leave_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_KVS_Node_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_KVS_Leave_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_KVS_Node_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_KVS_Node_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("PUT", pattern_KVS_Join_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -571,14 +661,14 @@ func RegisterKVSHandlerClient(ctx context.Context, mux *runtime.ServeMux, client runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_KVS_Node_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_KVS_Join_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_KVS_Node_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_KVS_Join_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -602,6 +692,26 @@ func RegisterKVSHandlerClient(ctx context.Context, mux *runtime.ServeMux, client }) + mux.Handle("DELETE", pattern_KVS_Leave_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_KVS_Leave_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_KVS_Leave_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_KVS_Snapshot_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -706,12 +816,14 @@ func RegisterKVSHandlerClient(ctx context.Context, mux *runtime.ServeMux, client } var ( - pattern_KVS_Leave_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "node", "id"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_KVS_Node_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "node"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_KVS_Join_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "cluster", "id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_KVS_Cluster_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "cluster"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_KVS_Leave_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "cluster", "id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_KVS_Snapshot_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "snapshot"}, "", runtime.AssumeColonVerbOpt(true))) pattern_KVS_Get_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 3, 0, 4, 1, 5, 2}, []string{"v1", "data", "key"}, "", runtime.AssumeColonVerbOpt(true))) @@ -724,12 +836,14 @@ var ( ) var ( - forward_KVS_Leave_0 = runtime.ForwardResponseMessage - forward_KVS_Node_0 = runtime.ForwardResponseMessage + forward_KVS_Join_0 = runtime.ForwardResponseMessage + forward_KVS_Cluster_0 = runtime.ForwardResponseMessage + forward_KVS_Leave_0 = runtime.ForwardResponseMessage + forward_KVS_Snapshot_0 = runtime.ForwardResponseMessage forward_KVS_Get_0 = runtime.ForwardResponseMessage diff --git a/protobuf/kvs/kvs.proto b/protobuf/kvs/kvs.proto index c31ce47..7f2846d 100644 --- a/protobuf/kvs/kvs.proto +++ b/protobuf/kvs/kvs.proto @@ -24,15 +24,15 @@ package kvs; option go_package = "github.com/mosuka/cete/protobuf/kvs"; service KVS { - rpc Join (JoinRequest) returns (google.protobuf.Empty) {} - rpc Leave (LeaveRequest) returns (google.protobuf.Empty) { + rpc Node (google.protobuf.Empty) returns (NodeResponse) { option (google.api.http) = { - delete: "/v1/node/{id}" + get: "/v1/node" }; } - rpc Node (google.protobuf.Empty) returns (NodeResponse) { + rpc Join (JoinRequest) returns (google.protobuf.Empty) { option (google.api.http) = { - get: "/v1/node" + put: "/v1/cluster/{id}" + body: "*" }; } rpc Cluster (google.protobuf.Empty) returns (ClusterResponse) { @@ -40,6 +40,11 @@ service KVS { get: "/v1/cluster" }; } + rpc Leave (LeaveRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/cluster/{id}" + }; + } rpc Snapshot (google.protobuf.Empty) returns (google.protobuf.Empty) { option (google.api.http) = {