This repo contains an approach of Golang's Pipelines and its features. It's organized on branches, so you can go through the different milestones:
- original-sketch: the original approach discussed on the go blog
- refactoring
- autogen-stages
- fanInfanOut
- cancellation
This repo exists because the first post in my blog, where I explain the pattern.
### A simple example:
double
----------
/ 1 3 -> 2 6 \
>-------< >------> [1, 2, 3] (maybe in other order)
1 2 3 \ 2 -> 4 / /2
----------
square
1st Stage 2nd Stage 3rd Stage
numbers := []int{1, 2, 3}
input := Converter(numbers...)
firstStage := Pipeline(identity)(input)
secondStage := FanOut(firstStage, RoundRobin, Pipeline(double), Pipeline(square))
merged := FanIn(secondStage...)
thirdStage := Pipeline(divideBy(2))(merged)
result := Sink(thirdStage)
fmt.Println(result) double
----------
/ 1 3 -> 2 6 \
>-------< >------> [1, 2, 3] (maybe in other order)
1 2 3 \ 2 -> 4 / /2
----------
square
1st Stage 2nd Stage 3rd Stage
numbers := []int{1, 2, 3}
input := Converter(numbers...)
firstStage := Pipeline(identity)(input)
secondStage := FanOut(firstStage, RoundRobin, Pipeline(double), Pipeline(square))
merged := FanIn(secondStage...)
thirdStage := Pipeline(divideBy(2))(merged)
result := SinkWithOrder(thirdStage, InOrder)
fmt.Println(result)- add more shedulers
- cancellation
- errors on observables
- order in merge
- tests
- benchmarks
- buffered channels?