github.com/micro/go-micro/examples@v0.0.0-20210105173217-bf4ab679e18b/template/api/proto/example/example.micro.go (about) 1 // Code generated by protoc-gen-micro. DO NOT EDIT. 2 // source: proto/example/example.proto 3 4 package go_micro_api_template 5 6 import ( 7 fmt "fmt" 8 proto "github.com/golang/protobuf/proto" 9 proto1 "github.com/micro/go-micro/v2/api/proto" 10 math "math" 11 ) 12 13 import ( 14 context "context" 15 client "github.com/micro/go-micro/v2/client" 16 server "github.com/micro/go-micro/v2/server" 17 ) 18 19 // Reference imports to suppress errors if they are not otherwise used. 20 var _ = proto.Marshal 21 var _ = fmt.Errorf 22 var _ = math.Inf 23 24 // This is a compile-time assertion to ensure that this generated file 25 // is compatible with the proto package it is being compiled against. 26 // A compilation error at this line likely means your copy of the 27 // proto package needs to be updated. 28 const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package 29 30 // Reference imports to suppress errors if they are not otherwise used. 31 var _ context.Context 32 var _ client.Option 33 var _ server.Option 34 35 // Client API for Example service 36 37 type ExampleService interface { 38 Call(ctx context.Context, in *proto1.Request, opts ...client.CallOption) (*proto1.Response, error) 39 } 40 41 type exampleService struct { 42 c client.Client 43 name string 44 } 45 46 func NewExampleService(name string, c client.Client) ExampleService { 47 if c == nil { 48 c = client.NewClient() 49 } 50 if len(name) == 0 { 51 name = "go.micro.api.template" 52 } 53 return &exampleService{ 54 c: c, 55 name: name, 56 } 57 } 58 59 func (c *exampleService) Call(ctx context.Context, in *proto1.Request, opts ...client.CallOption) (*proto1.Response, error) { 60 req := c.c.NewRequest(c.name, "Example.Call", in) 61 out := new(proto1.Response) 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 // Server API for Example service 70 71 type ExampleHandler interface { 72 Call(context.Context, *proto1.Request, *proto1.Response) error 73 } 74 75 func RegisterExampleHandler(s server.Server, hdlr ExampleHandler, opts ...server.HandlerOption) error { 76 type example interface { 77 Call(ctx context.Context, in *proto1.Request, out *proto1.Response) error 78 } 79 type Example struct { 80 example 81 } 82 h := &exampleHandler{hdlr} 83 return s.Handle(s.NewHandler(&Example{h}, opts...)) 84 } 85 86 type exampleHandler struct { 87 ExampleHandler 88 } 89 90 func (h *exampleHandler) Call(ctx context.Context, in *proto1.Request, out *proto1.Response) error { 91 return h.ExampleHandler.Call(ctx, in, out) 92 }