Skip to content

craftdome/go-pipeline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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