yanic/respond/multi_collector.go

30 lines
713 B
Go
Raw Normal View History

2016-03-09 02:49:27 +00:00
package respond
2016-03-11 23:59:36 +00:00
import (
"github.com/ffdo/node-informant/gluon-collector/data"
"time"
)
2016-03-09 02:49:27 +00:00
//MultiCollector struct
type MultiCollector struct {
collectors []*Collector
}
//NewMultiCollector create a list of collectors
2016-03-11 23:59:36 +00:00
func NewMultiCollector(interval time.Duration, onReceive OnReceive) *MultiCollector {
2016-03-09 02:49:27 +00:00
return &MultiCollector{
collectors: []*Collector{
2016-03-11 23:59:36 +00:00
NewCollector("statistics", interval, data.StatisticsStruct{}, onReceive),
NewCollector("nodeinfo", interval, data.NodeInfo{}, onReceive),
NewCollector("neighbours", interval, data.NeighbourStruct{}, onReceive),
2016-03-09 02:49:27 +00:00
},
}
}
//Close all Collections
func (multi *MultiCollector) Close() {
for _, col := range multi.collectors {
col.Close()
}
}