yanic/respond/multi_collector.go

30 lines
723 B
Go
Raw Normal View History

2016-03-09 03:49:27 +01:00
package respond
2016-03-12 00:59:36 +01:00
import (
"github.com/monitormap/micro-daemon/data"
2016-03-12 00:59:36 +01:00
"time"
)
2016-03-09 03:49:27 +01:00
//MultiCollector struct
type MultiCollector struct {
collectors []*Collector
}
//NewMultiCollector create a list of collectors
2016-03-12 00:59:36 +01:00
func NewMultiCollector(interval time.Duration, onReceive OnReceive) *MultiCollector {
2016-03-09 03:49:27 +01:00
return &MultiCollector{
collectors: []*Collector{
2016-03-12 18:26:51 +01:00
NewCollector("statistics", 0, interval, data.Statistics{}, onReceive),
NewCollector("nodeinfo", time.Second*3, interval, data.NodeInfo{}, onReceive),
NewCollector("neighbours", time.Second*6, interval, data.Neighbours{}, onReceive),
2016-03-09 03:49:27 +01:00
},
}
}
//Close all Collections
func (multi *MultiCollector) Close() {
for _, col := range multi.collectors {
col.Close()
}
}