31 lines
573 B
Go
31 lines
573 B
Go
|
|
package services
|
||
|
|
|
||
|
|
import (
|
||
|
|
"basic-sensor-receiver/config"
|
||
|
|
"database/sql"
|
||
|
|
)
|
||
|
|
|
||
|
|
type Services struct {
|
||
|
|
SensorConfig *SensorConfigService
|
||
|
|
SensorValues *SensorValuesService
|
||
|
|
Sensors *SensorsService
|
||
|
|
}
|
||
|
|
|
||
|
|
type Context struct {
|
||
|
|
DB *sql.DB
|
||
|
|
Config *config.Config
|
||
|
|
Services *Services
|
||
|
|
}
|
||
|
|
|
||
|
|
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}
|
||
|
|
|
||
|
|
return &services
|
||
|
|
}
|