-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
58 lines (48 loc) · 1.6 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
package main
import (
"context"
"log"
"github.com/android-project-46group/core-api/config"
"github.com/android-project-46group/core-api/handler"
db "github.com/android-project-46group/core-api/repository/database"
"github.com/android-project-46group/core-api/repository/remote"
"github.com/android-project-46group/core-api/usecase"
"github.com/android-project-46group/core-api/util"
"github.com/android-project-46group/core-api/util/logger"
"github.com/opentracing/opentracing-go"
)
func main() {
cfg, err := config.New()
if err != nil {
log.Fatal("failed to initialize configuration: ", err)
}
logger, fileCloser, err := logger.NewFileLogger(cfg.LogPath, "ubuntu", cfg.Service)
if err != nil {
log.Fatal("failed to initialize logger: ", err)
}
defer func() {
if err := fileCloser(); err != nil {
logger.Warnf(context.Background(), "failed to fileCloser: ", err)
}
}()
tracer, traceCloser, err := util.NewJaegerTracer(cfg.Service)
if err != nil {
logger.Errorf(context.Background(), "cannot initialize jaeger tracer: ", err)
}
defer func() {
if err := traceCloser.Close(); err != nil {
logger.Warnf(context.Background(), "failed to traceCloser: ", err)
}
}()
opentracing.SetGlobalTracer(tracer)
database, err := db.New(context.Background(), cfg, logger)
if err != nil {
logger.Errorf(context.Background(), "failed to db.New: ", err)
}
client := remote.New()
usecase := usecase.New(database, client, logger)
h := handler.New(cfg, logger, usecase)
if err := handler.ServeGRPC(cfg.GrpcPort, h); err != nil {
logger.Errorf(context.Background(), "failed to serve: %v", err)
}
}