-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
40 lines (31 loc) · 1.13 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
package main
import (
"google.golang.org/grpc"
"therealbroker/api"
"therealbroker/api/proto/src/broker/api/proto"
"therealbroker/internal/broker"
"therealbroker/internal/config"
"therealbroker/internal/repositories"
grpcPkg "therealbroker/pkg/grpc"
interceptor "therealbroker/pkg/grpc/interceptor"
"therealbroker/pkg/logger"
"therealbroker/pkg/postgresql"
"therealbroker/pkg/prometheus"
)
func main() {
conf := config.New("broker")
logger.Configure(conf.Log.Level)
prometheus.StartPrometheusServer(conf.Prometheus.Port)
brokerPostgres := postgresql.NewDB(&conf.Postgres, &repositories.MessagePostgres{})
messageRepo := repositories.NewMessagesPostgres(brokerPostgres)
//brokerCassandra := cassandra.NewDB(&conf.Cassandra)
//messageRepo := repositories.NewCasMessageRepo(brokerCassandra, &conf.Cassandra)
module := broker.NewModule(messageRepo)
grpcServer := grpc.NewServer(
grpc.UnaryInterceptor(interceptor.RPCMetricsInterceptor),
grpc.UnaryInterceptor(interceptor.ErrorLoggingInterceptor),
)
handler := api.New(module, conf)
proto.RegisterBrokerServer(grpcServer, handler)
grpcPkg.Serve(&conf.Grpc, grpcServer)
}