fix(pkg/config): use storage endpoints
changes: - Only one storage endpoint can be defined. This consists of a URL which can be used to specify whether the data is to be stored in a file or in a database.
This commit is contained in:
30
pkg/internal/distribute/distribute.go
Normal file
30
pkg/internal/distribute/distribute.go
Normal file
@ -0,0 +1,30 @@
|
||||
package distribute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/go-flucky/flucky/pkg/types"
|
||||
)
|
||||
|
||||
func MeasuredValues(ctx context.Context, channels int, inputChannel <-chan *types.MeasuredValue) []chan *types.MeasuredValue {
|
||||
outputChannels := make([]chan *types.MeasuredValue, channels)
|
||||
|
||||
for i := 0; i <= channels; i++ {
|
||||
outputChannel := make(chan *types.MeasuredValue)
|
||||
outputChannels = append(outputChannels, outputChannel)
|
||||
}
|
||||
|
||||
go func(ctx context.Context, inputChannel <-chan *types.MeasuredValue, outputChannels []chan *types.MeasuredValue) {
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case measuredValue, _ := <-inputChannel:
|
||||
for _, outputChannel := range outputChannels {
|
||||
outputChannel <- measuredValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}(ctx, inputChannel, outputChannels)
|
||||
|
||||
return outputChannels
|
||||
}
|
Reference in New Issue
Block a user