Skip to content

Latest commit

 

History

History
41 lines (29 loc) · 770 Bytes

README.md

File metadata and controls

41 lines (29 loc) · 770 Bytes

GitHub go.mod Go version (subdirectory of monorepo)

About

A module for assembling a data pipeline.

Features

  • Go channels & goroutines
  • Using generics for custom data
  • Chain of units

Quick start

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())
}