forked from yarpc/yarpc-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
44 lines (36 loc) · 1.13 KB
/
client.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
// Code generated by thriftrw-plugin-yarpc
// @generated
package weatherfx
import (
fx "go.uber.org/fx"
yarpc "go.uber.org/yarpc"
thrift "go.uber.org/yarpc/encoding/thrift"
weatherclient "go.uber.org/yarpc/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/weather/weatherclient"
)
// Params defines the dependencies for the Weather client.
type Params struct {
fx.In
Provider yarpc.ClientConfig
}
// Result defines the output of the Weather client module. It provides a
// Weather client to an Fx application.
type Result struct {
fx.Out
Client weatherclient.Interface
// We are using an fx.Out struct here instead of just returning a client
// so that we can add more values or add named versions of the client in
// the future without breaking any existing code.
}
// Client provides a Weather client to an Fx application using the given name
// for routing.
//
// fx.Provide(
// weatherfx.Client("..."),
// newHandler,
// )
func Client(name string, opts ...thrift.ClientOption) interface{} {
return func(p Params) Result {
client := weatherclient.New(p.Provider.ClientConfig(name), opts...)
return Result{Client: client}
}
}