-
Notifications
You must be signed in to change notification settings - Fork 3
/
module.go
50 lines (45 loc) · 1.53 KB
/
module.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
46
47
48
49
50
package transport
import (
"github.com/alexfalkowski/go-service/transport/grpc"
gprometheus "github.com/alexfalkowski/go-service/transport/grpc/metrics/prometheus"
gopentracing "github.com/alexfalkowski/go-service/transport/grpc/trace/opentracing"
"github.com/alexfalkowski/go-service/transport/http"
hprometheus "github.com/alexfalkowski/go-service/transport/http/metrics/prometheus"
hopentracing "github.com/alexfalkowski/go-service/transport/http/trace/opentracing"
"github.com/alexfalkowski/go-service/transport/nsq/marshaller"
nprometheus "github.com/alexfalkowski/go-service/transport/nsq/metrics/prometheus"
nopentracing "github.com/alexfalkowski/go-service/transport/nsq/trace/opentracing"
"go.uber.org/fx"
)
var (
// GRPCModule for fx.
GRPCModule = fx.Options(
fx.Provide(grpc.NewServer),
fx.Provide(grpc.UnaryServerInterceptor),
fx.Provide(grpc.StreamServerInterceptor),
fx.Provide(gprometheus.NewServerMetrics),
fx.Provide(gprometheus.NewClientMetrics),
fx.Provide(gopentracing.NewTracer),
)
// HTTPModule for fx.
HTTPModule = fx.Options(
fx.Provide(http.NewServer),
fx.Provide(hprometheus.NewServerMetrics),
fx.Provide(hprometheus.NewClientMetrics),
fx.Provide(hopentracing.NewTracer),
)
// NSQModule for fx.
NSQModule = fx.Options(
fx.Provide(nprometheus.NewProducerMetrics),
fx.Provide(nprometheus.NewConsumerMetrics),
fx.Provide(nopentracing.NewTracer),
fx.Provide(marshaller.NewMsgPack),
)
// Module for fx.
Module = fx.Options(
GRPCModule,
HTTPModule,
NSQModule,
fx.Invoke(Register),
)
)