go.uber.org/yarpc@v1.72.1/encoding/thrift/internal/observabilitytest/test/testservicefx/server.go (about) 1 // Code generated by thriftrw-plugin-yarpc 2 // @generated 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 testservicefx 25 26 import ( 27 fx "go.uber.org/fx" 28 transport "go.uber.org/yarpc/api/transport" 29 thrift "go.uber.org/yarpc/encoding/thrift" 30 testserviceserver "go.uber.org/yarpc/encoding/thrift/internal/observabilitytest/test/testserviceserver" 31 ) 32 33 // ServerParams defines the dependencies for the TestService server. 34 type ServerParams struct { 35 fx.In 36 37 Handler testserviceserver.Interface 38 } 39 40 // ServerResult defines the output of TestService server module. It provides the 41 // procedures of a TestService handler to an Fx application. 42 // 43 // The procedures are provided to the "yarpcfx" value group. Dig 1.2 or newer 44 // must be used for this feature to work. 45 type ServerResult struct { 46 fx.Out 47 48 Procedures []transport.Procedure `group:"yarpcfx"` 49 } 50 51 // Server provides procedures for TestService to an Fx application. It expects a 52 // testservicefx.Interface to be present in the container. 53 // 54 // fx.Provide( 55 // func(h *MyTestServiceHandler) testserviceserver.Interface { 56 // return h 57 // }, 58 // testservicefx.Server(), 59 // ) 60 func Server(opts ...thrift.RegisterOption) interface{} { 61 return func(p ServerParams) ServerResult { 62 procedures := testserviceserver.New(p.Handler, opts...) 63 return ServerResult{Procedures: procedures} 64 } 65 }