diff --git a/cmd/server/main.go b/cmd/server/main.go index 6758774..9c9e0a2 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -21,10 +21,16 @@ type coordinator interface { Start() } +// NewCoordinator creates a new coordinator that runs on the central server +// The coordinator is given an error channel to feed errors back to the main process should any arise +// The zero value for a new coordinator is ready to start func NewCoordinator(ch chan error) coordinator { return server.NewCentralCoordinator(ch) } +// LoadConfig loads a given config based on a string lookup +// Used to load the associated settings for a coordinator such as port and IP address as well as database settings +// LoadConfig expects the returned config to satisfy the interface func LoadConfig(fname string) Config { if err := config.Load(fname); err != nil { panic(err) @@ -32,6 +38,7 @@ func LoadConfig(fname string) Config { return config.LoadConfig() } +// Basic functions expected to be provided by the config structure type Config interface { UpdatePort(string, int) error Store() error @@ -49,6 +56,8 @@ func main() { errCh := make(chan error) // checking env envVars := os.Environ() + + // I can put this is a seperate func for _, envString := range envVars { // looping over set ports initSplt := strings.Split(envString, "=") diff --git a/internal/pkg/config/def.go b/internal/pkg/config/def.go index 5fc48ce..48ba739 100644 --- a/internal/pkg/config/def.go +++ b/internal/pkg/config/def.go @@ -2,6 +2,13 @@ package config // def.go serves as a central place to view/edit config structs and device manager map +/* +Notes: + - I think that this is scuffed as all hell and I can probably vastly improve this. + - First order of buisness is to rework these definitons to even make sense + - What does the server ACTUALLY need to know and vice versa for a reactor +*/ + import ( "sync" ) @@ -10,8 +17,9 @@ import ( type ServerConf struct { // Structure to demarshall into - Server ServerConfig `mapstructure:"server"` - Reactors map[string]ReactorConfig `mapstructure:"reactors"` + Server ServerConfig `mapstructure:"server"` + // I think this is unnessecary, who the hell cares? + //Reactors map[string]ReactorConfig `mapstructure:"reactors"` sync.RWMutex } @@ -28,8 +36,9 @@ type ServerConfig struct { type ReactorConf struct { // Structure to demarshall to - Reactor ReactorConfig `mapstructure:"reactor"` - Devices map[int]DeviceConfig `mapstructure:"devices"` + Reactor ReactorConfig `mapstructure:"reactor"` + // I think this is also unnessecary, again what does it matter? + // Devices map[int]DeviceConfig `mapstructure:"devices"` sync.RWMutex } diff --git a/internal/pkg/config/load.go b/internal/pkg/config/load.go index 54ea492..d0ffb78 100644 --- a/internal/pkg/config/load.go +++ b/internal/pkg/config/load.go @@ -20,7 +20,8 @@ import ( func NewConfig(name string) (Config, error) { // returns a Config Structure of assocaited name - return + return C, Load(name) +} type ConfigStruct interface { // structure to do demarshall config into