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