-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
34 lines (27 loc) · 945 Bytes
/
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
package main
import (
"context"
"log/slog"
"github.com/RouteHub-Link/routehub.client.hub/mq"
"github.com/RouteHub-Link/routehub.client.hub/server"
"github.com/RouteHub-Link/routehub.client.hub/services"
)
func main() {
ctx := context.Background()
services.NewLoggerConfigurer(slog.LevelDebug)
logger := services.GetLogger()
hostingMode := services.GetHostingMode()
cf := services.GetRedisConfig()
logger.Log(ctx, slog.LevelDebug, "redis config", slog.String("host", cf.Host), slog.String("port", cf.Port), slog.String("password", cf.Password), slog.Int("db", cf.DB))
rc := services.NewRedisClient(ctx, cf)
switch hostingMode {
case services.HostingModeRest:
logger.Log(ctx, slog.LevelDebug, "Rest Hosting Mode")
server.NewRestServer()
case services.HostingModeMQTT:
logger.Log(ctx, slog.LevelDebug, "MQTT Hosting Mode")
mq.NewMQTTServer(rc)
default:
logger.Log(ctx, slog.LevelError, "Invalid hosting mode")
}
}