-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
62 lines (54 loc) · 1.36 KB
/
main.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
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"github.com/sirupsen/logrus"
fxlogrus "github.com/takt-corp/fx-logrus"
"cbsr.io/golang-grpc-template/common/clients"
"cbsr.io/golang-grpc-template/common/controller"
"cbsr.io/golang-grpc-template/config"
"cbsr.io/golang-grpc-template/db"
"cbsr.io/golang-grpc-template/logger"
ping "cbsr.io/golang-grpc-template/modules/ping/controllers"
"cbsr.io/golang-grpc-template/modules/users/application"
users "cbsr.io/golang-grpc-template/modules/users/controllers"
"cbsr.io/golang-grpc-template/modules/users/repository"
"cbsr.io/golang-grpc-template/server"
"go.uber.org/fx"
"go.uber.org/fx/fxevent"
"google.golang.org/grpc"
)
func main() {
fx.New(
fx.WithLogger(func() fxevent.Logger {
return &fxlogrus.LogrusLogger{Logger: logrus.New()}
}),
// Provide configuration
fx.Provide(
config.New,
logger.New,
db.New,
server.New,
),
// Provide clients
fx.Provide(
clients.NewPingClient,
clients.NewUserClient,
),
// Provide repositories
fx.Provide(
repository.NewUserRepository,
),
// Provide services
fx.Provide(
application.NewUserService,
),
// Provide controllers
fx.Provide(
controller.FxController(ping.New),
controller.FxController(users.New),
),
// Register controllers
fx.Invoke(server.RegisterControllers),
// Start the server
fx.Invoke(func(*grpc.Server) {}),
).Run()
}