Skip to content

Latest commit

 

History

History
49 lines (39 loc) · 1.23 KB

README.md

File metadata and controls

49 lines (39 loc) · 1.23 KB

💥 Fusion

PkgGoDevGo Report Card

Fusion is a tiny stream processing library written in Go.

See 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:

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)
}