package collector_go import ( "loafle.com/overflow/agent_api/config_manager" "loafle.com/overflow/agent_api/observer" "loafle.com/overflow/agent_api/observer/messages" ) func handleConfigLoaded() { ch := make(chan interface{}, 0) observer.Add(messages.CONFIGMANAGER_LOADED, ch) data := <-ch confMng := data.(config_manager.ConfigManager) coll := GetInstance() coll.start(confMng) observer.Remove(messages.CONFIGMANAGER_LOADED, ch) } func handleSensorAdded(ch chan interface{}) { coll := GetInstance() observer.Add(messages.ADD_SENSOR_2_END, ch) for { configId := <-ch coll.addSensor(configId.(string)) } } func handleSensorRemoved(ch chan interface{}) { coll := GetInstance() observer.Add(messages.REMOVE_SENSOR_1, ch) for { configId := <-ch coll.removeSensor(configId.(string)) observer.Notify(messages.REMOVE_SENSOR_2_END, configId) } } func cleanObserver(ach chan interface{}, rch chan interface{}) { observer.Remove(messages.ADD_SENSOR_2_END, ach) observer.Remove(messages.REMOVE_SENSOR_1, rch) observer.Notify(messages.COLLECTOR_STOPPED, true) }