github.com/micro/go-micro/examples@v0.0.0-20210105173217-bf4ab679e18b/greeter/api/rpc/proto/hello/hello.micro.go (about) 1 // Code generated by protoc-gen-micro. DO NOT EDIT. 2 // source: github.com/micro/go-micro/examples/greeter/api/rpc/proto/hello/hello.proto 3 4 /* 5 Package go_micro_api_greeter is a generated protocol buffer package. 6 7 It is generated from these files: 8 github.com/micro/go-micro/examples/greeter/api/rpc/proto/hello/hello.proto 9 10 It has these top-level messages: 11 Request 12 Response 13 */ 14 package go_micro_api_greeter 15 16 import proto "github.com/golang/protobuf/proto" 17 import fmt "fmt" 18 import math "math" 19 20 import ( 21 context "context" 22 client "github.com/micro/go-micro/v2/client" 23 server "github.com/micro/go-micro/v2/server" 24 ) 25 26 // Reference imports to suppress errors if they are not otherwise used. 27 var _ = proto.Marshal 28 var _ = fmt.Errorf 29 var _ = math.Inf 30 31 // This is a compile-time assertion to ensure that this generated file 32 // is compatible with the proto package it is being compiled against. 33 // A compilation error at this line likely means your copy of the 34 // proto package needs to be updated. 35 const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package 36 37 // Reference imports to suppress errors if they are not otherwise used. 38 var _ context.Context 39 var _ client.Option 40 var _ server.Option 41 42 // Client API for Greeter service 43 44 type GreeterService interface { 45 Hello(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error) 46 } 47 48 type greeterService struct { 49 c client.Client 50 serviceName string 51 } 52 53 func NewGreeterService(serviceName string, c client.Client) GreeterService { 54 if c == nil { 55 c = client.NewClient() 56 } 57 if len(serviceName) == 0 { 58 serviceName = "go.micro.api.greeter" 59 } 60 return &greeterService{ 61 c: c, 62 serviceName: serviceName, 63 } 64 } 65 66 func (c *greeterService) Hello(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error) { 67 req := c.c.NewRequest(c.serviceName, "Greeter.Hello", in) 68 out := new(Response) 69 err := c.c.Call(ctx, req, out, opts...) 70 if err != nil { 71 return nil, err 72 } 73 return out, nil 74 } 75 76 // Server API for Greeter service 77 78 type GreeterHandler interface { 79 Hello(context.Context, *Request, *Response) error 80 } 81 82 func RegisterGreeterHandler(s server.Server, hdlr GreeterHandler, opts ...server.HandlerOption) { 83 type greeter interface { 84 Hello(ctx context.Context, in *Request, out *Response) error 85 } 86 type Greeter struct { 87 greeter 88 } 89 h := &greeterHandler{hdlr} 90 s.Handle(s.NewHandler(&Greeter{h}, opts...)) 91 } 92 93 type greeterHandler struct { 94 GreeterHandler 95 } 96 97 func (h *greeterHandler) Hello(ctx context.Context, in *Request, out *Response) error { 98 return h.GreeterHandler.Hello(ctx, in, out) 99 }