collector

This commit is contained in:
insanity@loafle.com 2017-05-16 16:44:02 +09:00
parent 58c6c696ad
commit f205c2e550

View File

@ -20,7 +20,7 @@ var (
type Collector struct { type Collector struct {
scheduler *s.Scheduler scheduler *s.Scheduler
cm cm.ConfigManager cm cm.ConfigManager
dataCh chan interface{} dataCh chan interface{}
} }
func Start(started chan bool, dataCh chan interface{}, conf cm.ConfigManager) { func Start(started chan bool, dataCh chan interface{}, conf cm.ConfigManager) {
@ -42,8 +42,6 @@ func GetInstance() *Collector {
return instance return instance
} }
func (c *Collector) start(started chan bool, conf cm.ConfigManager) { func (c *Collector) start(started chan bool, conf cm.ConfigManager) {
go func() { go func() {
c.cm = conf c.cm = conf
@ -59,7 +57,6 @@ func (c *Collector) start(started chan bool, conf cm.ConfigManager) {
}() }()
} }
func (c *Collector) stop() { func (c *Collector) stop() {
c.scheduler.RemoveAllSchedule() c.scheduler.RemoveAllSchedule()
c.scheduler.Stop() c.scheduler.Stop()
@ -107,8 +104,12 @@ func (c *Collector) removeSensor(id string) error {
return nil return nil
} }
func (c *Collector) updateSensor(id string) { func (c *Collector) updateSensor(id string) error {
//update err := c.removeSensor(id)
if err != nil {
return err
}
return c.addSensor(id)
} }
func AddSensor(id string) error { func AddSensor(id string) error {
@ -119,10 +120,14 @@ func RemSensor(id string) error {
return GetInstance().removeSensor(id) return GetInstance().removeSensor(id)
} }
func UpdateSensor(id string) error {
return GetInstance().updateSensor(id)
}
func StartSensor(id string) error { func StartSensor(id string) error {
return GetInstance().scheduler.StartSchedule(id) return GetInstance().scheduler.StartSchedule(id)
} }
func StopSensor(id string) error { func StopSensor(id string) error {
return GetInstance().scheduler.StopSchedule(id) return GetInstance().scheduler.StopSchedule(id)
} }