github.com/micro/go-micro/examples@v0.0.0-20210105173217-bf4ab679e18b/api/meta/proto/api.micro.go (about) 1 // Code generated by protoc-gen-micro. DO NOT EDIT. 2 // source: github.com/micro/go-micro/examples/api/meta/proto/api.proto 3 4 /* 5 Package api is a generated protocol buffer package. 6 7 It is generated from these files: 8 github.com/micro/go-micro/examples/api/meta/proto/api.proto 9 10 It has these top-level messages: 11 CallRequest 12 CallResponse 13 EmptyRequest 14 EmptyResponse 15 */ 16 package api 17 18 import proto "github.com/golang/protobuf/proto" 19 import fmt "fmt" 20 import math "math" 21 22 import ( 23 context "context" 24 client "github.com/micro/go-micro/v2/client" 25 server "github.com/micro/go-micro/v2/server" 26 ) 27 28 // Reference imports to suppress errors if they are not otherwise used. 29 var _ = proto.Marshal 30 var _ = fmt.Errorf 31 var _ = math.Inf 32 33 // This is a compile-time assertion to ensure that this generated file 34 // is compatible with the proto package it is being compiled against. 35 // A compilation error at this line likely means your copy of the 36 // proto package needs to be updated. 37 const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package 38 39 // Reference imports to suppress errors if they are not otherwise used. 40 var _ context.Context 41 var _ client.Option 42 var _ server.Option 43 44 // Client API for Example service 45 46 type ExampleService interface { 47 Call(ctx context.Context, in *CallRequest, opts ...client.CallOption) (*CallResponse, error) 48 } 49 50 type exampleService struct { 51 c client.Client 52 serviceName string 53 } 54 55 func NewExampleService(serviceName string, c client.Client) ExampleService { 56 if c == nil { 57 c = client.NewClient() 58 } 59 if len(serviceName) == 0 { 60 serviceName = "example" 61 } 62 return &exampleService{ 63 c: c, 64 serviceName: serviceName, 65 } 66 } 67 68 func (c *exampleService) Call(ctx context.Context, in *CallRequest, opts ...client.CallOption) (*CallResponse, error) { 69 req := c.c.NewRequest(c.serviceName, "Example.Call", in) 70 out := new(CallResponse) 71 err := c.c.Call(ctx, req, out, opts...) 72 if err != nil { 73 return nil, err 74 } 75 return out, nil 76 } 77 78 // Server API for Example service 79 80 type ExampleHandler interface { 81 Call(context.Context, *CallRequest, *CallResponse) error 82 } 83 84 func RegisterExampleHandler(s server.Server, hdlr ExampleHandler, opts ...server.HandlerOption) { 85 type example interface { 86 Call(ctx context.Context, in *CallRequest, out *CallResponse) error 87 } 88 type Example struct { 89 example 90 } 91 h := &exampleHandler{hdlr} 92 s.Handle(s.NewHandler(&Example{h}, opts...)) 93 } 94 95 type exampleHandler struct { 96 ExampleHandler 97 } 98 99 func (h *exampleHandler) Call(ctx context.Context, in *CallRequest, out *CallResponse) error { 100 return h.ExampleHandler.Call(ctx, in, out) 101 } 102 103 // Client API for Foo service 104 105 type FooService interface { 106 Bar(ctx context.Context, in *EmptyRequest, opts ...client.CallOption) (*EmptyResponse, error) 107 } 108 109 type fooService struct { 110 c client.Client 111 serviceName string 112 } 113 114 func NewFooService(serviceName string, c client.Client) FooService { 115 if c == nil { 116 c = client.NewClient() 117 } 118 if len(serviceName) == 0 { 119 serviceName = "foo" 120 } 121 return &fooService{ 122 c: c, 123 serviceName: serviceName, 124 } 125 } 126 127 func (c *fooService) Bar(ctx context.Context, in *EmptyRequest, opts ...client.CallOption) (*EmptyResponse, error) { 128 req := c.c.NewRequest(c.serviceName, "Foo.Bar", in) 129 out := new(EmptyResponse) 130 err := c.c.Call(ctx, req, out, opts...) 131 if err != nil { 132 return nil, err 133 } 134 return out, nil 135 } 136 137 // Server API for Foo service 138 139 type FooHandler interface { 140 Bar(context.Context, *EmptyRequest, *EmptyResponse) error 141 } 142 143 func RegisterFooHandler(s server.Server, hdlr FooHandler, opts ...server.HandlerOption) { 144 type foo interface { 145 Bar(ctx context.Context, in *EmptyRequest, out *EmptyResponse) error 146 } 147 type Foo struct { 148 foo 149 } 150 h := &fooHandler{hdlr} 151 s.Handle(s.NewHandler(&Foo{h}, opts...)) 152 } 153 154 type fooHandler struct { 155 FooHandler 156 } 157 158 func (h *fooHandler) Bar(ctx context.Context, in *EmptyRequest, out *EmptyResponse) error { 159 return h.FooHandler.Bar(ctx, in, out) 160 }