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.

License

Notifications You must be signed in to change notification settings

nutzhub/go-pipeline

 
 

Repository files navigation

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.

About

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.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%