diff --git a/cmd/fermentord/main.go b/cmd/fermentord/main.go index 0401610..0dfffef 100644 --- a/cmd/fermentord/main.go +++ b/cmd/fermentord/main.go @@ -24,7 +24,7 @@ import ( "github.com/spf13/viper" ) -func mainLoop(ctx context.Context, wg *sync.WaitGroup, js nats.JetStream, config *configuration.ControllerConfig) { +func mainLoop(ctx context.Context, wg *sync.WaitGroup, js nats.JetStream, config *configuration.Configuration) { hub := sentry.CurrentHub().Clone() defer hub.Flush(10 * time.Second) defer wg.Done() diff --git a/internal/api/http.go b/internal/api/http.go index edc098c..2913455 100644 --- a/internal/api/http.go +++ b/internal/api/http.go @@ -11,7 +11,7 @@ import ( ) type API struct { - config *configuration.ControllerConfig + config *configuration.Configuration configChangeCallback func() nc *nats.Conn } diff --git a/internal/configuration/config.go b/internal/configuration/config.go index 1e0824e..ca8eb75 100644 --- a/internal/configuration/config.go +++ b/internal/configuration/config.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/viper" ) -type ControllerConfig struct { +type Configuration struct { NATS struct { URL string `mapstructure:"url"` Stream string `mapstructure:"stream"` @@ -49,7 +49,7 @@ type ControllerConfig struct { } `mapstructure:"pid"` } -func LoadConfiguration() *ControllerConfig { +func LoadConfiguration() *Configuration { hub := sentry.CurrentHub().Clone() defer hub.Flush(10 * time.Second) @@ -79,7 +79,7 @@ func LoadConfiguration() *ControllerConfig { log.Printf("Error loading configuration: %v", err) } - config := &ControllerConfig{} + config := &Configuration{} if err := viper.Unmarshal(config); err != nil { hub.CaptureException(err) log.Fatal(err) diff --git a/internal/controllers/chamber.go b/internal/controllers/chamber.go index 6bbb78e..ee78ad5 100644 --- a/internal/controllers/chamber.go +++ b/internal/controllers/chamber.go @@ -27,8 +27,8 @@ var ChamberStateMap = map[ChamberState]string{ } type ChamberController struct { - ConfigUpdates chan configuration.ControllerConfig - config configuration.ControllerConfig + ConfigUpdates chan configuration.Configuration + config configuration.Configuration // Current state. chamberState ChamberState @@ -49,7 +49,7 @@ type ChamberController struct { hub *sentry.Hub } -func NewChamberController(name string, config configuration.ControllerConfig) *ChamberController { +func NewChamberController(name string, config configuration.Configuration) *ChamberController { return &ChamberController{ C: make(chan ChamberState), name: name, @@ -57,7 +57,7 @@ func NewChamberController(name string, config configuration.ControllerConfig) *C pid: NewPIDController(config.PID.Kp, config.PID.Ki, config.PID.Kd), chTemp: make(chan temperature.TemperatureReading), chamberState: ChamberStateIdle, - ConfigUpdates: make(chan configuration.ControllerConfig, 1), + ConfigUpdates: make(chan configuration.Configuration, 1), hub: sentry.CurrentHub().Clone(), } } diff --git a/internal/controllers/config.go b/internal/controllers/config.go index 02320b6..dd53d47 100644 --- a/internal/controllers/config.go +++ b/internal/controllers/config.go @@ -7,7 +7,7 @@ import ( "git.joco.dk/sng/fermentord/pkg/temperature" ) -func ReloadConfiguration(config *configuration.ControllerConfig, ctrl *ChamberController) { +func ReloadConfiguration(config *configuration.Configuration, ctrl *ChamberController) { log.Printf("Reloading configuration") temperature.ConfigUpdates <- []string{ diff --git a/internal/dwingest/nats.go b/internal/dwingest/nats.go index f16b5bc..9cd09a3 100644 --- a/internal/dwingest/nats.go +++ b/internal/dwingest/nats.go @@ -34,7 +34,7 @@ func (p *DWIngest) AddState(state controllers.ChamberState) { p.chState <- state } -func (p *DWIngest) Run(ctx context.Context, wg *sync.WaitGroup, js nats.JetStream, config *configuration.ControllerConfig) { +func (p *DWIngest) Run(ctx context.Context, wg *sync.WaitGroup, js nats.JetStream, config *configuration.Configuration) { hub := sentry.CurrentHub().Clone() defer hub.Flush(10 * time.Second) defer wg.Done()