pipeline

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2023 License: BSD-3-Clause Imports: 0 Imported by: 0

README

pipeline

Package pipeline allows you to use the Pipeline pattern in your processes.

Install

go get github.com/weiwenchen2022/pipeline

Examples

package main

import (
	"fmt"

	"github.com/weiwenchen2022/pipeline"
)

func main() {
	sq := func(in any) any {
		n := in.(int)
		return n * n
	}
	result := pipeline.New(2, 3).
		Through(pipeline.StageFunc(sq)).Out()
	for v := range result {
		fmt.Println(v)
	}
	// Output:
	// 4
	// 9
}

Spec

GoDoc: https://godoc.org/github.com/weiwenchen2022/pipeline

Documentation

Overview

Example
package main

import (
	"fmt"

	"github.com/weiwenchen2022/pipeline"
)

func main() {
	sq := func(in any) any {
		n := in.(int)
		return n * n
	}
	result := pipeline.New(2, 3).
		Through(pipeline.StageFunc(sq)).Out()
	for v := range result {
		fmt.Println(v)
	}
}
Output:

4
9

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pipeline

type Pipeline struct {
	// contains filtered or unexported fields
}

func New

func New(a ...any) *Pipeline

func (*Pipeline) Out

func (p *Pipeline) Out() <-chan any

func (*Pipeline) Through

func (p *Pipeline) Through(stages ...Stage) *Pipeline

type Stage

type Stage interface {
	Handle(any) any
}

type StageFunc

type StageFunc func(in any) any

func (StageFunc) Handle

func (f StageFunc) Handle(in any) any

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL