Coder Social home page Coder Social logo

papilo's Introduction

Papilo

Go

Stream data processing micro-framework; Read, clean, process and store data using pre-defined and custom pipelines.

Papilo packages common and simple data processing functions for reuse, allows definition of custom components/functions and allows permutations of them in powerful ways using the Pipes and Filters Architecture.

Features (WIP)

  • Pipeline stages: Read - Process - Store
  • Pre-defined pipelines: Papilo offers pre-defined pipelines and components
  • Custom pipelines: Organize components to create a custom pipeline flow
  • Concurrency: Run multiple pipelines concurrently
  • Extensibility: Extend by adding custom components
  • Network source: REST and WebSocket APIs for data ingress
  • Custom source: Define a custom source for data ingress
  • Multiple formats: Transform input and output data using transformation functions

Architecture

Architecture

The Pipes and Filters architectural pattern provides a structure for systems that process a stream of data. In this architecture, data is born from a data source, passes through pipes to intermediate stages called filter components and ends up in a data sink. Filter Components are the processing units of the pipeline, a filter can enrich (add information to) data, refine (remove information from) data and transform data by delivering data in some other representation. Any two components are connected by pipes; Pipes are the carriers of data into adjacent components. Although this can be implemented in any language, Go lends itself well to this architecture through the use of channels as pipes.

Defaults

Papilo offers default sources, sinks and components:

  • Sources:

    • File: Read lines from a file
    • Stdin: Read lines from standard input (default)
    • (WIP): Network: A REST endpoint is exposed on a port
    • (WIP): WebSocket: Full duplex communication, exposed on a port
  • Sinks:

    • File: Write sink data to file
    • Stdout: Write sink data to standard output (default)
  • Components:

    • Sum: Continuously push the sum of all previous numbers to the sink

Examples

Read from stdin, write to stdout:

package main

import "github.com/thealamu/papilo/pkg/papilo"

func main() {
	p := papilo.New()
	m := &papilo.Pipeline{} // Default data source is stdin, default data sink is stdout 
	p.Run(m)	
}

Add a stream of numbers:

func main() {
	p := papilo.New()
	m := &papilo.Pipeline{
		Components: []papilo.Component{papilo.SumComponent},
	}
	p.Run(m)
}

Make every character in stream lowercase using a custom component:

func lowerCmpt(p *papilo.Pipe) {
	for !p.IsClosed { // read for as long as the pipe is open
		// p.Next returns the next data in the pipe
		d, _ := p.Next()
		byteData, ok := d.([]byte)
		if !ok {
			// we did not receive a []byte, we can be resilient and move on
			continue
		}
		// Write to next pipe
		p.Write(bytes.ToLower(byteData))
	}
}

func main() {
	p := papilo.New()
	m := &papilo.Pipeline{
		Components: []papilo.Component{lowerCmpt},
	}
	p.Run(m)
}

papilo's People

Contributors

faithfulnessalamu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.