-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (32 loc) · 1.05 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
package main
import (
"github.com/large-scale-deployment/coordinator/handlers"
"github.com/large-scale-deployment/coordinator/models"
"github.com/large-scale-deployment/coordinator/services"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
func startService(ssHandler *handlers.ServiceStatusHandler, psHandler *handlers.PodStatusHandler) {
e := echo.New()
// Middleware
e.Use(middleware.Logger())
e.Use(middleware.Recover())
// Routes
e.POST("/registry/service_statuses", ssHandler.Create)
e.POST("/registry/pod_statuses", psHandler.Create)
// Start server
e.Logger.Fatal(e.Start(":1323"))
}
func main() {
db, err := gorm.Open(sqlite.Open("coordinator.db"), &gorm.Config{})
if err != nil {
panic("failed to connect database")
}
(&models.Models{DB: db}).AutoMigrate()
reg := &services.Registry{DB: db}
ssHandler := &handlers.ServiceStatusHandler{Registry: reg}
psHandler := &handlers.PodStatusHandler{Registry: reg}
startService(ssHandler, psHandler)
}