yanic/respond/multi_collector.go

30 lines
713 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/ffdo/node-informant/gluon-collector/data"
"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 00:59:36 +01:00
NewCollector("statistics", interval, data.StatisticsStruct{}, onReceive),
NewCollector("nodeinfo", interval, data.NodeInfo{}, onReceive),
NewCollector("neighbours", interval, data.NeighbourStruct{}, onReceive),
2016-03-09 03:49:27 +01:00
},
}
}
//Close all Collections
func (multi *MultiCollector) Close() {
for _, col := range multi.collectors {
col.Close()
}
}