trying to sift through the garbage

main
KeeganForelight 2 years ago
parent 86b2d69c26
commit 6a9775facc

@ -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, "=")

@ -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"
)
@ -11,7 +18,8 @@ import (
type ServerConf struct {
// Structure to demarshall into
Server ServerConfig `mapstructure:"server"`
Reactors map[string]ReactorConfig `mapstructure:"reactors"`
// I think this is unnessecary, who the hell cares?
//Reactors map[string]ReactorConfig `mapstructure:"reactors"`
sync.RWMutex
}
@ -29,7 +37,8 @@ type ServerConfig struct {
type ReactorConf struct {
// Structure to demarshall to
Reactor ReactorConfig `mapstructure:"reactor"`
Devices map[int]DeviceConfig `mapstructure:"devices"`
// I think this is also unnessecary, again what does it matter?
// Devices map[int]DeviceConfig `mapstructure:"devices"`
sync.RWMutex
}

@ -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

Loading…
Cancel
Save