go.uber.org/yarpc@v1.72.1/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/extends/namefx/server.go (about)

     1  // Code generated by thriftrw-plugin-yarpc
     2  // @generated
     3  
     4  package namefx
     5  
     6  import (
     7  	fx "go.uber.org/fx"
     8  	transport "go.uber.org/yarpc/api/transport"
     9  	thrift "go.uber.org/yarpc/encoding/thrift"
    10  	nameserver "go.uber.org/yarpc/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/extends/nameserver"
    11  )
    12  
    13  // ServerParams defines the dependencies for the Name server.
    14  type ServerParams struct {
    15  	fx.In
    16  
    17  	Handler nameserver.Interface
    18  }
    19  
    20  // ServerResult defines the output of Name server module. It provides the
    21  // procedures of a Name handler to an Fx application.
    22  //
    23  // The procedures are provided to the "yarpcfx" value group. Dig 1.2 or newer
    24  // must be used for this feature to work.
    25  type ServerResult struct {
    26  	fx.Out
    27  
    28  	Procedures []transport.Procedure `group:"yarpcfx"`
    29  }
    30  
    31  // Server provides procedures for Name to an Fx application. It expects a
    32  // namefx.Interface to be present in the container.
    33  //
    34  //	fx.Provide(
    35  //		func(h *MyNameHandler) nameserver.Interface {
    36  //			return h
    37  //		},
    38  //		namefx.Server(),
    39  //	)
    40  func Server(opts ...thrift.RegisterOption) interface{} {
    41  	return func(p ServerParams) ServerResult {
    42  		procedures := nameserver.New(p.Handler, opts...)
    43  		return ServerResult{Procedures: procedures}
    44  	}
    45  }