https://github.com/izniburak/pipeline-go
Pipeline pattern for your jobs, tasks, etc.. (Golang)
https://github.com/izniburak/pipeline-go
design-patterns go golang pipeline pipelines
Last synced: 6 months ago
JSON representation
Pipeline pattern for your jobs, tasks, etc.. (Golang)
- Host: GitHub
- URL: https://github.com/izniburak/pipeline-go
- Owner: izniburak
- License: mit
- Created: 2023-09-13T21:49:05.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-06-03T06:14:18.000Z (about 2 years ago)
- Last Synced: 2025-05-02T05:47:04.407Z (about 1 year ago)
- Topics: design-patterns, go, golang, pipeline, pipelines
- Language: Go
- Homepage:
- Size: 26.4 KB
- Stars: 56
- Watchers: 2
- Forks: 12
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# pipeline-go [](https://github.com/izniburak/pipeline-go/actions) [](https://pkg.go.dev/github.com/izniburak/pipeline-go)
This package allows you to use the Pipeline pattern in your processes, and it's built upon the Chain of Responsibility (CoR) design pattern.
CoR is a behavioral design pattern that processes given data through a series of handlers. When a request reaches the pipe class, it processes the data and then forwards it to the next handler. The principle behind this pattern is straightforward.

> In summary, the Pipeline is a design pattern tailored for managing sequential modifications to an object. Imagine it as an assembly line: each station represents a pipe, and by the end of the line, you're left with a transformed object.
## Install
```bash
go get github.com/izniburak/pipeline-go
```
## Examples
```go
package main
import (
"fmt"
"strings"
"github.com/izniburak/pipeline-go"
)
type UpperCasePipe struct{}
func (u *UpperCasePipe) Handle(value pipeline.PipeValue, next pipeline.PipeNext) pipeline.PipeValue {
// get value
text := value.(string)
capitalized := strings.ToUpper(text)
return next(capitalized)
}
type TrimSpacePipe struct{}
func (t *TrimSpacePipe) Handle(value pipeline.PipeValue, next pipeline.PipeNext) pipeline.PipeValue {
// get value
text := value.(string)
trimmed := strings.Trim(text, " ")
return next(trimmed)
}
func main() {
text := " buki.dev "
pipes := []pipeline.PipeInterface{
new(UpperCasePipe),
new(TrimSpacePipe),
}
result := pipeline.Send(text).Through(pipes).ThenReturn()
fmt.Println(result) // BUKI.DEV
}
```
## Contributing
1. Fork the repo (https://github.com/izniburak/pipeline-go/fork)
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create a new Pull Request
## Contributors
- [izniburak](https://github.com/izniburak) İzni Burak Demirtaş - creator, maintainer
## License
The MIT License (MIT) - see [`license.md`](https://github.com/izniburak/pipeline-go/blob/main/license.md) for more details