Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cyberdelia/pipeline
Compose I/O pipeline
https://github.com/cyberdelia/pipeline
Last synced: 29 days ago
JSON representation
Compose I/O pipeline
- Host: GitHub
- URL: https://github.com/cyberdelia/pipeline
- Owner: cyberdelia
- License: mit
- Created: 2014-09-22T22:24:51.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2021-08-07T23:38:17.000Z (over 3 years ago)
- Last Synced: 2024-05-02T05:54:00.939Z (7 months ago)
- Language: Go
- Homepage: https://pkg.go.dev/github.com/cyberdelia/pipeline
- Size: 6.84 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pipeline
Pipeline allows you to compose a pipeline of ``io.Reader`` or ``io.Writer``,
allowing you to process data easily.## Installation
Download and install :
```
$ go get github.com/cyberdelia/pipeline
```## Usage
Create your own pipes:
```go
package exampleimport (
"io"
"time""github.com/cyberdelia/pipeline"
"github.com/cyberdelia/ratio"
)func RateLimitWritePipeline(size int) pipeline.WritePipeline {
return func(w io.WriteCloser) (io.WriteCloser, error) {
return ratio.RateLimitedWriter(w, size, time.Second), nil
}
}func RateLimitReadPipeline(size int) pipeline.ReadPipeline {
return func(r io.ReadCloser) (io.ReadCloser, error) {
return ratio.RateLimitedReader(r, size, time.Second), nil
}
}func LZOWritePipeline(w io.WriteCloser) (io.WriteCloser, error) {
return lzo.NewWriter(w), nil
}func LZOReadPipeline(r io.ReadCloser) (io.ReadCloser, error) {
return lzo.NewReader(r)
}
```And compose a pipeline:
```go
pipe, err := pipeline.PipeWrite(w, RateLimitWritePipeline(10e6), LZOWritePipeline)
if err != nil {
...
}
io.Copy(pipe, file)
```