config_manager_go/init_method.go
jackdaw@loafle.com 5c5d1844a2 remodeling
2017-04-27 19:02:08 +09:00

36 lines
887 B
Go

package config_manager_go
import (
"loafle.com/overflow/agent_api/observer"
"loafle.com/overflow/agent_api/observer/messages"
)
func agentStartHandler() {
agentStart := make(chan interface{}, 0)
observer.Add("AGENT_STARTED", agentStart)
go func() {
data := <-agentStart
path := data.(string)
// load global config
_configManager.loadGlobalConfig(path + "/" + "global.yaml")
// load all crawler configs
if err := _configManager.loadCrawlerConfigAll(); err != nil {
// error process
}
observer.Remove(messages.AGENT_STARTED, agentStart)
observer.Notify(messages.CONFIGMANAGER_LOADED, _configManager)
}()
}
func removeSensorHandler() {
observer.Add(messages.REMOVE_SENSOR_0,_configManager.removeCh)
go _configManager.removeConfig()
}
func addSensorHandler() {
observer.Add(messages.ADD_SENSOR_0,_configManager.addCh)
go _configManager.addConfig()
}