pipefilter

package
v0.0.0-...-48c9e09 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package pipefilter is to define the interfaces and the structures for pipe-filter style implementation

Index

Constants

This section is empty.

Variables

View Source
var SplitFilterWrongFormatError = errors.New("input data should be string")
View Source
var SumFilterWrongFormatError = errors.New("input data should be []int")
View Source
var ToIntFilterWrongFormatError = errors.New("input data should be []string")

Functions

This section is empty.

Types

type Filter

type Filter interface {
	Process(data Request) (Response, error)
}

Filter interface is the definition of the data processing components Pipe-Filter structure

type Request

type Request interface{}

Request is the input of the filter

type Response

type Response interface{}

Response is the output of the filter

type SplitFilter

type SplitFilter struct {
	// contains filtered or unexported fields
}

func NewSplitFilter

func NewSplitFilter(delimiter string) *SplitFilter

func (*SplitFilter) Process

func (sf *SplitFilter) Process(data Request) (Response, error)

type StraightPipeline

type StraightPipeline struct {
	Name    string
	Filters *[]Filter
}

StraightPipeline is composed of the filters, and the filters are piled as a straigt line.

func NewStraightPipeline

func NewStraightPipeline(name string, filters ...Filter) *StraightPipeline

NewStraightPipeline create a new StraightPipelineWithWallTime

func (*StraightPipeline) Process

func (f *StraightPipeline) Process(data Request) (Response, error)

Process is to process the coming data by the pipeline

type SumFilter

type SumFilter struct {
}

func NewSumFilter

func NewSumFilter() *SumFilter

func (*SumFilter) Process

func (sf *SumFilter) Process(data Request) (Response, error)

type ToIntFilter

type ToIntFilter struct {
}

func NewToIntFilter

func NewToIntFilter() *ToIntFilter

func (*ToIntFilter) Process

func (tif *ToIntFilter) Process(data Request) (Response, error)

Jump to

Keyboard shortcuts

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