command_pipeline

package module
v0.0.0-...-cb7cb74 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2016 License: MIT Imports: 2 Imported by: 0

README

Build Status

Command pipeline

CommandPipeline is a lightweight high performance pipeline (using "concurrency" to execute the commands) for Go.

Usage

This is just a quick introduction

Let's start with a trivial Hello World example:

    package main

    import (
        "github.com/donutloop/command-pipeline"
        "bytes"
    )

    func main() {

	    buildCommand := func(letter string) func(input *bytes.Buffer) (*bytes.Buffer, error) {
        		return func(input *bytes.Buffer) (*bytes.Buffer, error) {
        
        			input.WriteString(letter)
        
        			return input, nil
        		}
        	}
        
        	firstInput := bytes.NewBufferString("H")
        
        	pipeline := command_pipeline.New(
        		firstInput,
        		buildCommand("E"),
        		buildCommand("L"),
        		buildCommand("L"),
        		buildCommand("O"),
        		buildCommand(" "),
        		buildCommand("W"),
        		buildCommand("O"),
        		buildCommand("R"),
        		buildCommand("L"),
        		buildCommand("D"),
        	)
        
        	data, _ := pipeline.Execute()
        
        	print(data.String()) //Output: HELLO WORLD
    }

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(input *bytes.Buffer, command ...Execute) *commandPipeline

New builds a new command pipeline The parameter "Input" is a inital value for the command pipeline. The parameters "command" are commands for the command pipline

Types

type Execute

type Execute func(*bytes.Buffer) (*bytes.Buffer, error)

Execute is function that represent a Command for the command pipeline

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL