From f205c2e550fc71a0d743d54a6123987c6a987965 Mon Sep 17 00:00:00 2001 From: "insanity@loafle.com" Date: Tue, 16 May 2017 16:44:02 +0900 Subject: [PATCH] collector --- collector.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/collector.go b/collector.go index 60f205b..07edbe0 100644 --- a/collector.go +++ b/collector.go @@ -20,7 +20,7 @@ var ( type Collector struct { scheduler *s.Scheduler cm cm.ConfigManager - dataCh chan interface{} + dataCh chan interface{} } func Start(started chan bool, dataCh chan interface{}, conf cm.ConfigManager) { @@ -42,8 +42,6 @@ func GetInstance() *Collector { return instance } - - func (c *Collector) start(started chan bool, conf cm.ConfigManager) { go func() { c.cm = conf @@ -59,7 +57,6 @@ func (c *Collector) start(started chan bool, conf cm.ConfigManager) { }() } - func (c *Collector) stop() { c.scheduler.RemoveAllSchedule() c.scheduler.Stop() @@ -107,8 +104,12 @@ func (c *Collector) removeSensor(id string) error { return nil } -func (c *Collector) updateSensor(id string) { - //update +func (c *Collector) updateSensor(id string) error { + err := c.removeSensor(id) + if err != nil { + return err + } + return c.addSensor(id) } func AddSensor(id string) error { @@ -119,10 +120,14 @@ func RemSensor(id string) error { return GetInstance().removeSensor(id) } +func UpdateSensor(id string) error { + return GetInstance().updateSensor(id) +} + func StartSensor(id string) error { return GetInstance().scheduler.StartSchedule(id) } func StopSensor(id string) error { return GetInstance().scheduler.StopSchedule(id) -} \ No newline at end of file +}