services decoupling

This commit is contained in:
2026-09-21 11:45:10 +01:00
parent 5d5b7bfdc3
commit 263d3c29a3
12 changed files with 134 additions and 63 deletions
+32
View File
@@ -1,2 +1,34 @@
// Package services interacts with the other libraries required for this UI
package services
import (
"errors"
"log/slog"
)
type Orchestrator struct {
DeviceService *DeviceService
TelemetryService *TelemetryService
Messages chan string
}
func NewOrchestrator(logger *slog.Logger) (*Orchestrator, error) {
msg := make(chan string, 10)
devService := NewDeviceService(logger.With("service", "DeviceService"), msg)
telemService := NewTelemetryService(logger.With("service", "TelemetryService"), devService, msg)
if telemService == nil {
return nil, errors.New("failed to create telemetry service")
}
go telemService.FindProvider(telemService.CtxMonitor)
// Need to setup the callbacks on the services
return &Orchestrator{
DeviceService: devService,
TelemetryService: telemService,
Messages: msg,
}, nil
}