gitee.com/liuxuezhan/go-micro-v1.18.0@v1.0.0/server/proto/server.pb.micro.go (about) 1 // Code generated by protoc-gen-micro. DO NOT EDIT. 2 // source: gitee.com/liuxuezhan/go-micro-v1.18.0/server/proto/server.proto 3 4 package go_micro_server 5 6 import ( 7 fmt "fmt" 8 proto "github.com/golang/protobuf/proto" 9 math "math" 10 ) 11 12 import ( 13 context "context" 14 client "gitee.com/liuxuezhan/go-micro-v1.18.0/client" 15 server "gitee.com/liuxuezhan/go-micro-v1.18.0/server" 16 ) 17 18 // Reference imports to suppress errors if they are not otherwise used. 19 var _ = proto.Marshal 20 var _ = fmt.Errorf 21 var _ = math.Inf 22 23 // This is a compile-time assertion to ensure that this generated file 24 // is compatible with the proto package it is being compiled against. 25 // A compilation error at this line likely means your copy of the 26 // proto package needs to be updated. 27 const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package 28 29 // Reference imports to suppress errors if they are not otherwise used. 30 var _ context.Context 31 var _ client.Option 32 var _ server.Option 33 34 // Client API for Server service 35 36 type ServerService interface { 37 Handle(ctx context.Context, in *HandleRequest, opts ...client.CallOption) (*HandleResponse, error) 38 Subscribe(ctx context.Context, in *SubscribeRequest, opts ...client.CallOption) (*SubscribeResponse, error) 39 } 40 41 type serverService struct { 42 c client.Client 43 name string 44 } 45 46 func NewServerService(name string, c client.Client) ServerService { 47 if c == nil { 48 c = client.NewClient() 49 } 50 if len(name) == 0 { 51 name = "go.micro.server" 52 } 53 return &serverService{ 54 c: c, 55 name: name, 56 } 57 } 58 59 func (c *serverService) Handle(ctx context.Context, in *HandleRequest, opts ...client.CallOption) (*HandleResponse, error) { 60 req := c.c.NewRequest(c.name, "Server.Handle", in) 61 out := new(HandleResponse) 62 err := c.c.Call(ctx, req, out, opts...) 63 if err != nil { 64 return nil, err 65 } 66 return out, nil 67 } 68 69 func (c *serverService) Subscribe(ctx context.Context, in *SubscribeRequest, opts ...client.CallOption) (*SubscribeResponse, error) { 70 req := c.c.NewRequest(c.name, "Server.Subscribe", in) 71 out := new(SubscribeResponse) 72 err := c.c.Call(ctx, req, out, opts...) 73 if err != nil { 74 return nil, err 75 } 76 return out, nil 77 } 78 79 // Server API for Server service 80 81 type ServerHandler interface { 82 Handle(context.Context, *HandleRequest, *HandleResponse) error 83 Subscribe(context.Context, *SubscribeRequest, *SubscribeResponse) error 84 } 85 86 func RegisterServerHandler(s server.Server, hdlr ServerHandler, opts ...server.HandlerOption) error { 87 type server interface { 88 Handle(ctx context.Context, in *HandleRequest, out *HandleResponse) error 89 Subscribe(ctx context.Context, in *SubscribeRequest, out *SubscribeResponse) error 90 } 91 type Server struct { 92 server 93 } 94 h := &serverHandler{hdlr} 95 return s.Handle(s.NewHandler(&Server{h}, opts...)) 96 } 97 98 type serverHandler struct { 99 ServerHandler 100 } 101 102 func (h *serverHandler) Handle(ctx context.Context, in *HandleRequest, out *HandleResponse) error { 103 return h.ServerHandler.Handle(ctx, in, out) 104 } 105 106 func (h *serverHandler) Subscribe(ctx context.Context, in *SubscribeRequest, out *SubscribeResponse) error { 107 return h.ServerHandler.Subscribe(ctx, in, out) 108 }