-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
34 lines (28 loc) · 817 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"context"
"fmt"
"github.com/codyoss/flo"
)
func main() {
inputChannel := make(chan string, 1)
inputChannel <- "Hello World"
close(inputChannel)
// Set the default parallelism for the workflow to 5. This means each step added will have 5 worker goroutines and
// write to a channel with a buffer of 5.
flo.NewBuilder(flo.WithInput(inputChannel), flo.WithParallelism(5)).
Add(exclaim).
// This step will only have 3 worker goroutines and a output channel with a buffer of 3.
Add(exclaim, flo.WithStepParallelism(3)).
Add(print).
BuildAndExecute(context.Background())
// Output:
// Hello World!!
}
func exclaim(ctx context.Context, msg string) (string, error) {
return msg + "!", nil
}
func print(ctx context.Context, msg string) error {
fmt.Println(msg)
return nil
}