-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
35 lines (29 loc) · 791 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
35
package main
import (
"context"
"fmt"
"github.com/codyoss/flo"
)
func main() {
inputChannel := make(chan string, 2)
inputChannel <- "Hello World"
inputChannel <- "Another message"
close(inputChannel)
// make an output channel to receive data from the flo
outputChannel := make(chan string, 1)
// Register the output channel
flo.NewBuilder(flo.WithInput(inputChannel), flo.WithOutput(outputChannel)).
Add(exclaim).
Add(exclaim).
BuildAndExecute(context.Background())
fmt.Println(<-outputChannel)
fmt.Println(<-outputChannel)
// It is your responsibility to close this channel once the flo shutsdown
close(outputChannel)
// Output:
// Hello World!!!
// Another message!!!
}
func exclaim(ctx context.Context, msg string) (string, error) {
return msg + "!", nil
}