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