Skip to content

mhmtszr/pipeline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

7937dff · Jul 5, 2024

History

16 Commits
Jul 5, 2024
Mar 18, 2023
Mar 18, 2023
Mar 18, 2023
Mar 17, 2023
Mar 22, 2023
Mar 18, 2023
Jul 5, 2024
Jul 5, 2024
Jul 5, 2024
Jul 5, 2024
Jul 5, 2024

Repository files navigation

Pipeline GoDoc Build Status Coverage Status Go Report Card

133256800-8d51f5e5-1cc5-45d2-a195-28e95f1cb92c

Go pipeline solution that can be used in many different combinations for chaining pipeline steps.

Inspired by @bilal-kilic's Kotlin implementation boru.

Usage

Supports 1.18+ Go versions because of Go Generics

go get github.com/mhmtszr/pipeline

Examples

package main

import (
	"fmt"
	"github.com/mhmtszr/pipeline"
)

type Square struct{}
type Add struct{}

func (s Square) Execute(context int, next func(context int)) {
	context = context * context
	println(fmt.Sprintf("After first chain context: %d", context))
	next(context)
}

func (a Add) Execute(context int, next func(context int)) {
	context = context + context
	println(fmt.Sprintf("After second chain context: %d", context))
	next(context)
}

func main() {
	p := pipeline.Builder[int]{}.UsePipelineStep(Square{}).UsePipelineStep(Add{}).Build()
	p.Execute(3)
}
// After first chain context: 9
// After second chain context: 18