2019-06-25 20:22:34 +00:00
|
|
|
package collect
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/go-flucky/flucky/pkg/types"
|
|
|
|
)
|
|
|
|
|
2019-12-07 15:53:49 +00:00
|
|
|
func MeasuredValues(measuredValueChannel <-chan *types.MeasuredValue) []*types.MeasuredValue {
|
2019-07-02 20:33:01 +00:00
|
|
|
cachedMeasuredValues := make([]*types.MeasuredValue, 0)
|
2019-06-25 20:22:34 +00:00
|
|
|
for {
|
|
|
|
select {
|
2019-12-07 15:53:49 +00:00
|
|
|
case measuredValue, more := <-measuredValueChannel:
|
2019-06-25 20:22:34 +00:00
|
|
|
if more {
|
2019-12-07 15:53:49 +00:00
|
|
|
cachedMeasuredValues = append(cachedMeasuredValues, measuredValue)
|
2019-06-25 20:22:34 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return cachedMeasuredValues
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|