collector
This commit is contained in:
parent
58c6c696ad
commit
f205c2e550
19
collector.go
19
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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user