-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (38 loc) · 1.38 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
package main
import (
"github.com/eneskzlcn/catbyte-test-task/internal/config"
"github.com/eneskzlcn/catbyte-test-task/internal/message"
"github.com/eneskzlcn/catbyte-test-task/internal/processor"
"github.com/eneskzlcn/catbyte-test-task/internal/reporting"
"github.com/eneskzlcn/catbyte-test-task/rabbitmq"
"github.com/eneskzlcn/catbyte-test-task/redis"
"github.com/eneskzlcn/catbyte-test-task/server"
"log"
"os"
)
func main() {
//does not in any other environment (prod, qa or etc.) yet. So directly load local config.
config, err := config.LoadConfig(".dev/", "local", "yaml")
if err != nil {
return
}
rabbitMQClient := rabbitmq.New(config.RabbitMQ.Address, config.RabbitMQ.Queue)
redisClient := redis.NewClient(config.Redis.Address, config.Redis.Password)
//app 1: message api
messageService := message.NewService(rabbitMQClient)
messageHandler := message.NewHandler(messageService)
//app 2: processor
processorService := processor.NewService(rabbitMQClient, redisClient)
go processorService.StartProcessing()
//app 3: reporting
reportingService := reporting.NewService(redisClient)
reportingHandler := reporting.NewHandler(reportingService)
server := server.NewServer([]server.Handler{
messageHandler,
reportingHandler,
}, config.Server.TrustedProxies, config.Server.Port)
if err = server.Start(); err != nil {
log.Println("server closed with error")
os.Exit(1)
}
}