Skip to content
go-pipeline is a Go library to provide some channel "middleware"-like functionality. It can lead to some clean code when processing various inputs that share a flow.
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.travis.yml
LICENSE
README.md
definitions.go
definitions_test.go
doc.go
examples_test.go
ratelimiter.go
ratelimiter_test.go

README.md

go-pipeline

Build Status Coverage Status Go Report Card GoDoc

go-pipeline is a Go library to provide some channel "middleware"-like functionality. It can lead to some clean code when processing various inputs that share a flow.

Runner

The Runner interface provides much of the functionality in the package. It's defined as

type Runner interface {
	Run(chan interface{}) chan interface{}
}

The two implementing types provided are Operator and Flow, where the latter is just a collection of Operators, and both provide a Run method.

Example:

func multiplier(x int) Operator {
	return Operator(func(in chan interface{}, out chan interface{}) {
		for m := range in {
			n := m.(int)
			out <- (int(n) * x)
		}
	})
}

Rate Limiter

This package also provides a RateLimiter function which takes a rate limiter from the "golang.org/x/time/rate" package, and returns an Operator which returns a channel whose input is throttled by the provided rate limiter.

Examples

More examples of how to use the pipeline package can be found in the test files

Contributing

If you'd like to contribute to this project, make sure that you're running go vet and go lint before submitting a pull request. If adding a feature or fixing a bug, please also add a test case verify the new functionality/new fix.

You can’t perform that action at this time.