https://github.com/spy16/fusion
💥 Fusion is a tiny stream processing library written in Go.
https://github.com/spy16/fusion
go golang golang-library library stream-processing stream-processor streams
Last synced: 4 months ago
JSON representation
💥 Fusion is a tiny stream processing library written in Go.
- Host: GitHub
- URL: https://github.com/spy16/fusion
- Owner: spy16
- License: mit
- Created: 2020-07-20T16:14:56.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-01-21T09:38:07.000Z (almost 5 years ago)
- Last Synced: 2024-06-20T06:39:36.684Z (over 1 year ago)
- Topics: go, golang, golang-library, library, stream-processing, stream-processor, streams
- Language: Go
- Homepage:
- Size: 139 KB
- Stars: 17
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 💥 Fusion
[](https://pkg.go.dev/github.com/spy16/fusion)[](https://goreportcard.com/report/github.com/spy16/fusion)
Fusion is a tiny stream processing library written in `Go`.
See [reactor](./reactor) for a stream processing tool built using fusion.
## Features
* Simple & lightweight.
* Highly Composable. Compose `Proc` implementations in a way that is similar to middleware pattern to get concurrent
processing, automatic retries etc.
* Use for simple single node or more complex distributed setup by using different
`fusion.Stream` and `fusion.Proc` implementations.
* Zero dependencies.
## Usage
A simple line counter implementation:
```go
package main
import (
"context"
"fmt"
"os"
"sync/atomic"
"github.com/spy16/fusion"
)
func main() {
count := int64(0)
runner := fusion.Runner{
Stream: &fusion.LineStream{From: os.Stdin},
Proc: &fusion.Fn{
Workers: 5,
Func: func(ctx context.Context, msg fusion.Msg) error {
atomic.AddInt64(&count, 1)
return nil
},
},
}
_ = runner.Run(context.Background())
fmt.Printf("Count=%d\n", count)
}
```