From ac5eb5da47c62f9ca24d3a0049cfb8a89cabc564 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Sun, 22 Sep 2019 15:31:07 +0100 Subject: [PATCH] Remove fmt --- server/proto/server.micro.go | 108 ++++++++++++ server/proto/server.pb.go | 314 +++++++++++++++++++++++++++++++++++ server/proto/server.proto | 22 +++ server/server.go | 1 - 4 files changed, 444 insertions(+), 1 deletion(-) create mode 100644 server/proto/server.micro.go create mode 100644 server/proto/server.pb.go create mode 100644 server/proto/server.proto diff --git a/server/proto/server.micro.go b/server/proto/server.micro.go new file mode 100644 index 00000000..2f95eaf6 --- /dev/null +++ b/server/proto/server.micro.go @@ -0,0 +1,108 @@ +// Code generated by protoc-gen-micro. DO NOT EDIT. +// source: micro/go-micro/server/proto/server.proto + +package go_micro_server + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +import ( + context "context" + client "github.com/micro/go-micro/client" + server "github.com/micro/go-micro/server" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ client.Option +var _ server.Option + +// Client API for Server service + +type ServerService interface { + Handle(ctx context.Context, in *HandleRequest, opts ...client.CallOption) (*HandleResponse, error) + Subscribe(ctx context.Context, in *SubscribeRequest, opts ...client.CallOption) (*SubscribeResponse, error) +} + +type serverService struct { + c client.Client + name string +} + +func NewServerService(name string, c client.Client) ServerService { + if c == nil { + c = client.NewClient() + } + if len(name) == 0 { + name = "go.micro.server" + } + return &serverService{ + c: c, + name: name, + } +} + +func (c *serverService) Handle(ctx context.Context, in *HandleRequest, opts ...client.CallOption) (*HandleResponse, error) { + req := c.c.NewRequest(c.name, "Server.Handle", in) + out := new(HandleResponse) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serverService) Subscribe(ctx context.Context, in *SubscribeRequest, opts ...client.CallOption) (*SubscribeResponse, error) { + req := c.c.NewRequest(c.name, "Server.Subscribe", in) + out := new(SubscribeResponse) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// Server API for Server service + +type ServerHandler interface { + Handle(context.Context, *HandleRequest, *HandleResponse) error + Subscribe(context.Context, *SubscribeRequest, *SubscribeResponse) error +} + +func RegisterServerHandler(s server.Server, hdlr ServerHandler, opts ...server.HandlerOption) error { + type server interface { + Handle(ctx context.Context, in *HandleRequest, out *HandleResponse) error + Subscribe(ctx context.Context, in *SubscribeRequest, out *SubscribeResponse) error + } + type Server struct { + server + } + h := &serverHandler{hdlr} + return s.Handle(s.NewHandler(&Server{h}, opts...)) +} + +type serverHandler struct { + ServerHandler +} + +func (h *serverHandler) Handle(ctx context.Context, in *HandleRequest, out *HandleResponse) error { + return h.ServerHandler.Handle(ctx, in, out) +} + +func (h *serverHandler) Subscribe(ctx context.Context, in *SubscribeRequest, out *SubscribeResponse) error { + return h.ServerHandler.Subscribe(ctx, in, out) +} diff --git a/server/proto/server.pb.go b/server/proto/server.pb.go new file mode 100644 index 00000000..e3b8d327 --- /dev/null +++ b/server/proto/server.pb.go @@ -0,0 +1,314 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: micro/go-micro/server/proto/server.proto + +package go_micro_server + +import ( + context "context" + fmt "fmt" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type HandleRequest struct { + Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` + Endpoint string `protobuf:"bytes,2,opt,name=endpoint,proto3" json:"endpoint,omitempty"` + Protocol string `protobuf:"bytes,3,opt,name=protocol,proto3" json:"protocol,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *HandleRequest) Reset() { *m = HandleRequest{} } +func (m *HandleRequest) String() string { return proto.CompactTextString(m) } +func (*HandleRequest) ProtoMessage() {} +func (*HandleRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_aabeb7f1c6b4fe84, []int{0} +} + +func (m *HandleRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_HandleRequest.Unmarshal(m, b) +} +func (m *HandleRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_HandleRequest.Marshal(b, m, deterministic) +} +func (m *HandleRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_HandleRequest.Merge(m, src) +} +func (m *HandleRequest) XXX_Size() int { + return xxx_messageInfo_HandleRequest.Size(m) +} +func (m *HandleRequest) XXX_DiscardUnknown() { + xxx_messageInfo_HandleRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_HandleRequest proto.InternalMessageInfo + +func (m *HandleRequest) GetService() string { + if m != nil { + return m.Service + } + return "" +} + +func (m *HandleRequest) GetEndpoint() string { + if m != nil { + return m.Endpoint + } + return "" +} + +func (m *HandleRequest) GetProtocol() string { + if m != nil { + return m.Protocol + } + return "" +} + +type HandleResponse struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *HandleResponse) Reset() { *m = HandleResponse{} } +func (m *HandleResponse) String() string { return proto.CompactTextString(m) } +func (*HandleResponse) ProtoMessage() {} +func (*HandleResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_aabeb7f1c6b4fe84, []int{1} +} + +func (m *HandleResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_HandleResponse.Unmarshal(m, b) +} +func (m *HandleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_HandleResponse.Marshal(b, m, deterministic) +} +func (m *HandleResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_HandleResponse.Merge(m, src) +} +func (m *HandleResponse) XXX_Size() int { + return xxx_messageInfo_HandleResponse.Size(m) +} +func (m *HandleResponse) XXX_DiscardUnknown() { + xxx_messageInfo_HandleResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_HandleResponse proto.InternalMessageInfo + +type SubscribeRequest struct { + Topic string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SubscribeRequest) Reset() { *m = SubscribeRequest{} } +func (m *SubscribeRequest) String() string { return proto.CompactTextString(m) } +func (*SubscribeRequest) ProtoMessage() {} +func (*SubscribeRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_aabeb7f1c6b4fe84, []int{2} +} + +func (m *SubscribeRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SubscribeRequest.Unmarshal(m, b) +} +func (m *SubscribeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SubscribeRequest.Marshal(b, m, deterministic) +} +func (m *SubscribeRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SubscribeRequest.Merge(m, src) +} +func (m *SubscribeRequest) XXX_Size() int { + return xxx_messageInfo_SubscribeRequest.Size(m) +} +func (m *SubscribeRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SubscribeRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SubscribeRequest proto.InternalMessageInfo + +func (m *SubscribeRequest) GetTopic() string { + if m != nil { + return m.Topic + } + return "" +} + +type SubscribeResponse struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SubscribeResponse) Reset() { *m = SubscribeResponse{} } +func (m *SubscribeResponse) String() string { return proto.CompactTextString(m) } +func (*SubscribeResponse) ProtoMessage() {} +func (*SubscribeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_aabeb7f1c6b4fe84, []int{3} +} + +func (m *SubscribeResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SubscribeResponse.Unmarshal(m, b) +} +func (m *SubscribeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SubscribeResponse.Marshal(b, m, deterministic) +} +func (m *SubscribeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SubscribeResponse.Merge(m, src) +} +func (m *SubscribeResponse) XXX_Size() int { + return xxx_messageInfo_SubscribeResponse.Size(m) +} +func (m *SubscribeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_SubscribeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_SubscribeResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*HandleRequest)(nil), "go.micro.server.HandleRequest") + proto.RegisterType((*HandleResponse)(nil), "go.micro.server.HandleResponse") + proto.RegisterType((*SubscribeRequest)(nil), "go.micro.server.SubscribeRequest") + proto.RegisterType((*SubscribeResponse)(nil), "go.micro.server.SubscribeResponse") +} + +func init() { + proto.RegisterFile("micro/go-micro/server/proto/server.proto", fileDescriptor_aabeb7f1c6b4fe84) +} + +var fileDescriptor_aabeb7f1c6b4fe84 = []byte{ + // 228 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0xcd, 0x4e, 0xc4, 0x20, + 0x14, 0x85, 0xad, 0xc6, 0xea, 0xdc, 0x44, 0x1d, 0xd1, 0x05, 0xe9, 0xc2, 0x1f, 0x56, 0xdd, 0xc8, + 0x24, 0xfa, 0x12, 0x26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 0xff, 0xff, 0xf9, 0xb8, 0x5c, 0x69, + 0xa5, 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// ServerClient is the client API for Server service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ServerClient interface { + Handle(ctx context.Context, in *HandleRequest, opts ...grpc.CallOption) (*HandleResponse, error) + Subscribe(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (*SubscribeResponse, error) +} + +type serverClient struct { + cc *grpc.ClientConn +} + +func NewServerClient(cc *grpc.ClientConn) ServerClient { + return &serverClient{cc} +} + +func (c *serverClient) Handle(ctx context.Context, in *HandleRequest, opts ...grpc.CallOption) (*HandleResponse, error) { + out := new(HandleResponse) + err := c.cc.Invoke(ctx, "/go.micro.server.Server/Handle", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serverClient) Subscribe(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (*SubscribeResponse, error) { + out := new(SubscribeResponse) + err := c.cc.Invoke(ctx, "/go.micro.server.Server/Subscribe", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ServerServer is the server API for Server service. +type ServerServer interface { + Handle(context.Context, *HandleRequest) (*HandleResponse, error) + Subscribe(context.Context, *SubscribeRequest) (*SubscribeResponse, error) +} + +func RegisterServerServer(s *grpc.Server, srv ServerServer) { + s.RegisterService(&_Server_serviceDesc, srv) +} + +func _Server_Handle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(HandleRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServerServer).Handle(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/go.micro.server.Server/Handle", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServerServer).Handle(ctx, req.(*HandleRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Server_Subscribe_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SubscribeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServerServer).Subscribe(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/go.micro.server.Server/Subscribe", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServerServer).Subscribe(ctx, req.(*SubscribeRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Server_serviceDesc = grpc.ServiceDesc{ + ServiceName: "go.micro.server.Server", + HandlerType: (*ServerServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Handle", + Handler: _Server_Handle_Handler, + }, + { + MethodName: "Subscribe", + Handler: _Server_Subscribe_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "micro/go-micro/server/proto/server.proto", +} diff --git a/server/proto/server.proto b/server/proto/server.proto new file mode 100644 index 00000000..2440edbe --- /dev/null +++ b/server/proto/server.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package go.micro.server; + +service Server { + rpc Handle(HandleRequest) returns (HandleResponse) {}; + rpc Subscribe(SubscribeRequest) returns (SubscribeResponse) {}; +} + +message HandleRequest { + string service = 1; + string endpoint = 2; + string protocol = 3; +} + +message HandleResponse {} + +message SubscribeRequest { + string topic = 1; +} + +message SubscribeResponse {} diff --git a/server/server.go b/server/server.go index 84346716..5c8d5e4e 100644 --- a/server/server.go +++ b/server/server.go @@ -3,7 +3,6 @@ package server import ( "context" - "fmt" "os" "os/signal" "syscall"