A module for assembling a data pipeline.
- Go channels & goroutines
- Using generics for custom data
- Chain of units
package main
import (
"context"
"fmt"
"github.com/craftdome/go-pipeline"
)
func main() {
// Initializing a unit with <string> as input type and <int> as output
unit := pipeline.NewUnit[string, int]()
// An action that the unit performs
unit.OnExecute = func(s string) (int, error) {
return len(s), nil
}
unit.Start()
unit.Input() <- "my_string"
strLen := <-unit.Output()
fmt.Println(strLen)
unit.Stop(context.Background())
}