Add documentation

This commit is contained in:
Holger Obermaier 2022-01-26 12:08:40 +01:00
parent 9bd8a3a90b
commit 3d073080f8

View File

@ -30,7 +30,7 @@ type metricRouterConfig struct {
type metricRouter struct { type metricRouter struct {
inputs []chan lp.CCMetric // List of all input channels inputs []chan lp.CCMetric // List of all input channels
outputs []chan lp.CCMetric // List of all output channels outputs []chan lp.CCMetric // List of all output channels
done chan bool // channel to finish stop metric router done chan bool // channel to finish / stop metric router
wg *sync.WaitGroup wg *sync.WaitGroup
timestamp time.Time // timestamp timestamp time.Time // timestamp
ticker mct.MultiChanTicker ticker mct.MultiChanTicker
@ -200,19 +200,23 @@ func (r *metricRouter) Start() {
cclog.ComponentDebug("MetricRouter", "STARTED") cclog.ComponentDebug("MetricRouter", "STARTED")
} }
// AddInput adds a input channel to the metric router
func (r *metricRouter) AddInput(input chan lp.CCMetric) { func (r *metricRouter) AddInput(input chan lp.CCMetric) {
r.inputs = append(r.inputs, input) r.inputs = append(r.inputs, input)
} }
// AddOutput adds a output channel to the metric router
func (r *metricRouter) AddOutput(output chan lp.CCMetric) { func (r *metricRouter) AddOutput(output chan lp.CCMetric) {
r.outputs = append(r.outputs, output) r.outputs = append(r.outputs, output)
} }
// Close finishes / stops the metric router
func (r *metricRouter) Close() { func (r *metricRouter) Close() {
r.done <- true r.done <- true
cclog.ComponentDebug("MetricRouter", "CLOSE") cclog.ComponentDebug("MetricRouter", "CLOSE")
} }
// New creates a new initialized metric router
func New(ticker mct.MultiChanTicker, wg *sync.WaitGroup, routerConfigFile string) (MetricRouter, error) { func New(ticker mct.MultiChanTicker, wg *sync.WaitGroup, routerConfigFile string) (MetricRouter, error) {
r := new(metricRouter) r := new(metricRouter)
err := r.Init(ticker, wg, routerConfigFile) err := r.Init(ticker, wg, routerConfigFile)