2022-08-13 23:33:50 +02:00
|
|
|
package services
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"basic-sensor-receiver/config"
|
2024-03-29 09:55:51 +01:00
|
|
|
"basic-sensor-receiver/integrations"
|
2022-08-13 23:33:50 +02:00
|
|
|
"database/sql"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Services struct {
|
2024-03-29 09:55:51 +01:00
|
|
|
SensorConfig *SensorConfigService
|
|
|
|
|
SensorValues *SensorValuesService
|
|
|
|
|
Sensors *SensorsService
|
|
|
|
|
Sessions *SessionsService
|
|
|
|
|
Auth *AuthService
|
|
|
|
|
Dashboards *DashboardsService
|
|
|
|
|
Alerts *AlertsService
|
|
|
|
|
ContactPoints *ContactPointsService
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Integrations struct {
|
|
|
|
|
Telegram *integrations.TelegramIntegration
|
2022-08-13 23:33:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Context struct {
|
2024-03-29 09:55:51 +01:00
|
|
|
DB *sql.DB
|
|
|
|
|
Config *config.Config
|
|
|
|
|
Services *Services
|
|
|
|
|
Integrations *Integrations
|
2022-08-13 23:33:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func InitializeServices(ctx *Context) *Services {
|
|
|
|
|
services := Services{}
|
|
|
|
|
|
|
|
|
|
ctx.Services = &services
|
|
|
|
|
|
|
|
|
|
services.SensorConfig = &SensorConfigService{ctx: ctx}
|
|
|
|
|
services.SensorValues = &SensorValuesService{ctx: ctx}
|
|
|
|
|
services.Sensors = &SensorsService{ctx: ctx}
|
2022-08-21 19:33:30 +02:00
|
|
|
services.Sessions = &SessionsService{ctx: ctx}
|
|
|
|
|
services.Auth = &AuthService{ctx: ctx}
|
2022-08-23 23:35:36 +02:00
|
|
|
services.Dashboards = &DashboardsService{ctx: ctx}
|
2024-03-29 09:55:51 +01:00
|
|
|
services.Alerts = &AlertsService{ctx: ctx}
|
|
|
|
|
services.ContactPoints = &ContactPointsService{ctx: ctx}
|
|
|
|
|
|
|
|
|
|
ctx.Integrations = &Integrations{}
|
|
|
|
|
ctx.Integrations.Telegram = &integrations.TelegramIntegration{}
|
2022-08-13 23:33:50 +02:00
|
|
|
|
|
|
|
|
return &services
|
|
|
|
|
}
|