go.uber.org/yarpc@v1.72.1/encoding/protobuf/internal/testpb/v2/test.pb.yarpc.go (about) 1 // Code generated by protoc-gen-yarpc-go. DO NOT EDIT. 2 // source: encoding/protobuf/internal/testpb/v2/test.proto 3 4 // Copyright (c) 2022 Uber Technologies, Inc. 5 // 6 // Permission is hereby granted, free of charge, to any person obtaining a copy 7 // of this software and associated documentation files (the "Software"), to deal 8 // in the Software without restriction, including without limitation the rights 9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 // copies of the Software, and to permit persons to whom the Software is 11 // furnished to do so, subject to the following conditions: 12 // 13 // The above copyright notice and this permission notice shall be included in 14 // all copies or substantial portions of the Software. 15 // 16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 // THE SOFTWARE. 23 24 package testpb 25 26 import ( 27 "context" 28 "io/ioutil" 29 "reflect" 30 31 "go.uber.org/fx" 32 "go.uber.org/yarpc" 33 "go.uber.org/yarpc/api/transport" 34 "go.uber.org/yarpc/api/x/restriction" 35 "go.uber.org/yarpc/encoding/protobuf/reflection" 36 "go.uber.org/yarpc/encoding/protobuf/v2" 37 "google.golang.org/protobuf/proto" 38 ) 39 40 var _ = ioutil.NopCloser 41 42 // TestYARPCClient is the YARPC client-side interface for the Test service. 43 type TestYARPCClient interface { 44 Unary(context.Context, *TestMessage, ...yarpc.CallOption) (*TestMessage, error) 45 Duplex(context.Context, ...yarpc.CallOption) (TestServiceDuplexYARPCClient, error) 46 } 47 48 // TestServiceDuplexYARPCClient sends TestMessages and receives TestMessages, returning io.EOF when the stream is complete. 49 type TestServiceDuplexYARPCClient interface { 50 Context() context.Context 51 Send(*TestMessage, ...yarpc.StreamOption) error 52 Recv(...yarpc.StreamOption) (*TestMessage, error) 53 CloseSend(...yarpc.StreamOption) error 54 } 55 56 func newTestYARPCClient(clientConfig transport.ClientConfig, anyResolver v2.AnyResolver, options ...v2.ClientOption) TestYARPCClient { 57 return &_TestYARPCCaller{v2.NewStreamClient( 58 v2.ClientParams{ 59 ServiceName: "uber.yarpc.encoding.protobuf.Test", 60 ClientConfig: clientConfig, 61 AnyResolver: anyResolver, 62 Options: options, 63 }, 64 )} 65 } 66 67 // NewTestYARPCClient builds a new YARPC client for the Test service. 68 func NewTestYARPCClient(clientConfig transport.ClientConfig, options ...v2.ClientOption) TestYARPCClient { 69 return newTestYARPCClient(clientConfig, nil, options...) 70 } 71 72 // TestYARPCServer is the YARPC server-side interface for the Test service. 73 type TestYARPCServer interface { 74 Unary(context.Context, *TestMessage) (*TestMessage, error) 75 Duplex(TestServiceDuplexYARPCServer) error 76 } 77 78 // TestServiceDuplexYARPCServer receives TestMessages and sends TestMessage. 79 type TestServiceDuplexYARPCServer interface { 80 Context() context.Context 81 Recv(...yarpc.StreamOption) (*TestMessage, error) 82 Send(*TestMessage, ...yarpc.StreamOption) error 83 } 84 85 type buildTestYARPCProceduresParams struct { 86 Server TestYARPCServer 87 AnyResolver v2.AnyResolver 88 } 89 90 func buildTestYARPCProcedures(params buildTestYARPCProceduresParams) []transport.Procedure { 91 handler := &_TestYARPCHandler{params.Server} 92 return v2.BuildProcedures( 93 v2.BuildProceduresParams{ 94 ServiceName: "uber.yarpc.encoding.protobuf.Test", 95 UnaryHandlerParams: []v2.BuildProceduresUnaryHandlerParams{ 96 { 97 MethodName: "Unary", 98 Handler: v2.NewUnaryHandler( 99 v2.UnaryHandlerParams{ 100 Handle: handler.Unary, 101 NewRequest: newTestServiceUnaryYARPCRequest, 102 AnyResolver: params.AnyResolver, 103 }, 104 ), 105 }, 106 }, 107 OnewayHandlerParams: []v2.BuildProceduresOnewayHandlerParams{}, 108 StreamHandlerParams: []v2.BuildProceduresStreamHandlerParams{ 109 { 110 MethodName: "Duplex", 111 Handler: v2.NewStreamHandler( 112 v2.StreamHandlerParams{ 113 Handle: handler.Duplex, 114 }, 115 ), 116 }, 117 }, 118 }, 119 ) 120 } 121 122 // BuildTestYARPCProcedures prepares an implementation of the Test service for YARPC registration. 123 func BuildTestYARPCProcedures(server TestYARPCServer) []transport.Procedure { 124 return buildTestYARPCProcedures(buildTestYARPCProceduresParams{Server: server}) 125 } 126 127 // FxTestYARPCClientParams defines the input 128 // for NewFxTestYARPCClient. It provides the 129 // paramaters to get a TestYARPCClient in an 130 // Fx application. 131 type FxTestYARPCClientParams struct { 132 fx.In 133 134 Provider yarpc.ClientConfig 135 AnyResolver v2.AnyResolver `name:"yarpcfx" optional:"true"` 136 Restriction restriction.Checker `optional:"true"` 137 } 138 139 // FxTestYARPCClientResult defines the output 140 // of NewFxTestYARPCClient. It provides a 141 // TestYARPCClient to an Fx application. 142 type FxTestYARPCClientResult struct { 143 fx.Out 144 145 Client TestYARPCClient 146 147 // We are using an fx.Out struct here instead of just returning a client 148 // so that we can add more values or add named versions of the client in 149 // the future without breaking any existing code. 150 } 151 152 // NewFxTestYARPCClient provides a TestYARPCClient 153 // to an Fx application using the given name for routing. 154 // 155 // fx.Provide( 156 // testpb.NewFxTestYARPCClient("service-name"), 157 // ... 158 // ) 159 func NewFxTestYARPCClient(name string, options ...v2.ClientOption) interface{} { 160 return func(params FxTestYARPCClientParams) FxTestYARPCClientResult { 161 cc := params.Provider.ClientConfig(name) 162 163 if params.Restriction != nil { 164 if namer, ok := cc.GetUnaryOutbound().(transport.Namer); ok { 165 if err := params.Restriction.Check(v2.Encoding, namer.TransportName()); err != nil { 166 panic(err.Error()) 167 } 168 } 169 } 170 171 return FxTestYARPCClientResult{ 172 Client: newTestYARPCClient(cc, params.AnyResolver, options...), 173 } 174 } 175 } 176 177 // FxTestYARPCProceduresParams defines the input 178 // for NewFxTestYARPCProcedures. It provides the 179 // paramaters to get TestYARPCServer procedures in an 180 // Fx application. 181 type FxTestYARPCProceduresParams struct { 182 fx.In 183 184 Server TestYARPCServer 185 AnyResolver v2.AnyResolver `name:"yarpcfx" optional:"true"` 186 } 187 188 // FxTestYARPCProceduresResult defines the output 189 // of NewFxTestYARPCProcedures. It provides 190 // TestYARPCServer procedures to an Fx application. 191 // 192 // The procedures are provided to the "yarpcfx" value group. 193 // Dig 1.2 or newer must be used for this feature to work. 194 type FxTestYARPCProceduresResult struct { 195 fx.Out 196 197 Procedures []transport.Procedure `group:"yarpcfx"` 198 ReflectionMeta reflection.ServerMeta `group:"yarpcfx"` 199 } 200 201 // NewFxTestYARPCProcedures provides TestYARPCServer procedures to an Fx application. 202 // It expects a TestYARPCServer to be present in the container. 203 // 204 // fx.Provide( 205 // testpb.NewFxTestYARPCProcedures(), 206 // ... 207 // ) 208 func NewFxTestYARPCProcedures() interface{} { 209 return func(params FxTestYARPCProceduresParams) FxTestYARPCProceduresResult { 210 return FxTestYARPCProceduresResult{ 211 Procedures: buildTestYARPCProcedures(buildTestYARPCProceduresParams{ 212 Server: params.Server, 213 AnyResolver: params.AnyResolver, 214 }), 215 ReflectionMeta: reflection.ServerMeta{ 216 ServiceName: "uber.yarpc.encoding.protobuf.Test", 217 FileDescriptors: yarpcFileDescriptorClosure24cc393f48a441ad, 218 }, 219 } 220 } 221 } 222 223 type _TestYARPCCaller struct { 224 streamClient v2.StreamClient 225 } 226 227 func (c *_TestYARPCCaller) Unary(ctx context.Context, request *TestMessage, options ...yarpc.CallOption) (*TestMessage, error) { 228 responseMessage, err := c.streamClient.Call(ctx, "Unary", request, newTestServiceUnaryYARPCResponse, options...) 229 if responseMessage == nil { 230 return nil, err 231 } 232 response, ok := responseMessage.(*TestMessage) 233 if !ok { 234 return nil, v2.CastError(emptyTestServiceUnaryYARPCResponse, responseMessage) 235 } 236 return response, err 237 } 238 239 func (c *_TestYARPCCaller) Duplex(ctx context.Context, options ...yarpc.CallOption) (TestServiceDuplexYARPCClient, error) { 240 stream, err := c.streamClient.CallStream(ctx, "Duplex", options...) 241 if err != nil { 242 return nil, err 243 } 244 return &_TestServiceDuplexYARPCClient{stream: stream}, nil 245 } 246 247 type _TestYARPCHandler struct { 248 server TestYARPCServer 249 } 250 251 func (h *_TestYARPCHandler) Unary(ctx context.Context, requestMessage proto.Message) (proto.Message, error) { 252 var request *TestMessage 253 var ok bool 254 if requestMessage != nil { 255 request, ok = requestMessage.(*TestMessage) 256 if !ok { 257 return nil, v2.CastError(emptyTestServiceUnaryYARPCRequest, requestMessage) 258 } 259 } 260 response, err := h.server.Unary(ctx, request) 261 if response == nil { 262 return nil, err 263 } 264 return response, err 265 } 266 267 func (h *_TestYARPCHandler) Duplex(serverStream *v2.ServerStream) error { 268 return h.server.Duplex(&_TestServiceDuplexYARPCServer{serverStream: serverStream}) 269 } 270 271 type _TestServiceDuplexYARPCClient struct { 272 stream *v2.ClientStream 273 } 274 275 func (c *_TestServiceDuplexYARPCClient) Context() context.Context { 276 return c.stream.Context() 277 } 278 279 func (c *_TestServiceDuplexYARPCClient) Send(request *TestMessage, options ...yarpc.StreamOption) error { 280 return c.stream.Send(request, options...) 281 } 282 283 func (c *_TestServiceDuplexYARPCClient) Recv(options ...yarpc.StreamOption) (*TestMessage, error) { 284 responseMessage, err := c.stream.Receive(newTestServiceDuplexYARPCResponse, options...) 285 if responseMessage == nil { 286 return nil, err 287 } 288 response, ok := responseMessage.(*TestMessage) 289 if !ok { 290 return nil, v2.CastError(emptyTestServiceDuplexYARPCResponse, responseMessage) 291 } 292 return response, err 293 } 294 295 func (c *_TestServiceDuplexYARPCClient) CloseSend(options ...yarpc.StreamOption) error { 296 return c.stream.Close(options...) 297 } 298 299 type _TestServiceDuplexYARPCServer struct { 300 serverStream *v2.ServerStream 301 } 302 303 func (s *_TestServiceDuplexYARPCServer) Context() context.Context { 304 return s.serverStream.Context() 305 } 306 307 func (s *_TestServiceDuplexYARPCServer) Recv(options ...yarpc.StreamOption) (*TestMessage, error) { 308 requestMessage, err := s.serverStream.Receive(newTestServiceDuplexYARPCRequest, options...) 309 if requestMessage == nil { 310 return nil, err 311 } 312 request, ok := requestMessage.(*TestMessage) 313 if !ok { 314 return nil, v2.CastError(emptyTestServiceDuplexYARPCRequest, requestMessage) 315 } 316 return request, err 317 } 318 319 func (s *_TestServiceDuplexYARPCServer) Send(response *TestMessage, options ...yarpc.StreamOption) error { 320 return s.serverStream.Send(response, options...) 321 } 322 323 func newTestServiceUnaryYARPCRequest() proto.Message { 324 return &TestMessage{} 325 } 326 327 func newTestServiceUnaryYARPCResponse() proto.Message { 328 return &TestMessage{} 329 } 330 331 func newTestServiceDuplexYARPCRequest() proto.Message { 332 return &TestMessage{} 333 } 334 335 func newTestServiceDuplexYARPCResponse() proto.Message { 336 return &TestMessage{} 337 } 338 339 var ( 340 emptyTestServiceUnaryYARPCRequest = &TestMessage{} 341 emptyTestServiceUnaryYARPCResponse = &TestMessage{} 342 emptyTestServiceDuplexYARPCRequest = &TestMessage{} 343 emptyTestServiceDuplexYARPCResponse = &TestMessage{} 344 ) 345 346 var yarpcFileDescriptorClosure24cc393f48a441ad = [][]byte{ 347 // encoding/protobuf/internal/testpb/v2/test.proto 348 []byte{ 349 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4f, 0xcd, 0x4b, 0xce, 350 0x4f, 0xc9, 0xcc, 0x4b, 0xd7, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0xcf, 0xcc, 351 0x2b, 0x49, 0x2d, 0xca, 0x4b, 0xcc, 0xd1, 0x2f, 0x49, 0x2d, 0x2e, 0x29, 0x48, 0xd2, 0x2f, 0x33, 352 0x02, 0xb3, 0xf4, 0xc0, 0x0a, 0x84, 0x64, 0x4a, 0x93, 0x52, 0x8b, 0xf4, 0x2a, 0x13, 0x8b, 0x0a, 353 0x92, 0xf5, 0x60, 0x7a, 0xf5, 0x60, 0x7a, 0x95, 0x94, 0xb9, 0xb8, 0x43, 0x52, 0x8b, 0x4b, 0x7c, 354 0x53, 0x8b, 0x8b, 0x13, 0xd3, 0x53, 0x85, 0x44, 0xb8, 0x58, 0xcb, 0x12, 0x73, 0x4a, 0x53, 0x25, 355 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x20, 0x1c, 0xa3, 0x93, 0x8c, 0x5c, 0x2c, 0x20, 0x55, 0x42, 356 0xb1, 0x5c, 0xac, 0xa1, 0x79, 0x89, 0x45, 0x95, 0x42, 0x9a, 0x7a, 0xf8, 0x4c, 0xd5, 0x43, 0x32, 357 0x52, 0x8a, 0x78, 0xa5, 0x42, 0x49, 0x5c, 0x6c, 0x2e, 0xa5, 0x05, 0x39, 0xa9, 0x15, 0xb4, 0x31, 358 0x5f, 0x83, 0xd1, 0x80, 0xd1, 0x49, 0x37, 0x4a, 0x9b, 0x98, 0x10, 0xb4, 0x86, 0xb0, 0x92, 0xd8, 359 0xc0, 0x6a, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x9f, 0xcf, 0x84, 0x05, 0x77, 0x01, 0x00, 360 0x00, 361 }, 362 } 363 364 func init() { 365 yarpc.RegisterClientBuilder( 366 func(clientConfig transport.ClientConfig, structField reflect.StructField) TestYARPCClient { 367 return NewTestYARPCClient(clientConfig, v2.ClientBuilderOptions(clientConfig, structField)...) 368 }, 369 ) 370 }