pipeline

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 0 Imported by: 6

Documentation

Overview

Package pipeline provides simple implementations of Pipeline for use in pre-processing streamline.Stream output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrMap added in v0.2.0

type ErrMap func(line []byte) ([]byte, error)

ErrMap is a Pipeline that allows modifications of individual lines from streamline.Stream with error handling. Implementations can return a nil []byte to indicate a line is to be skipped.

Errors interrupt line processing and are propagated to streamline.Stream.

func (ErrMap) Inactive added in v0.2.0

func (m ErrMap) Inactive() bool

func (ErrMap) ProcessLine added in v0.2.0

func (m ErrMap) ProcessLine(line []byte) ([]byte, error)

type Filter added in v0.2.0

type Filter func(line []byte) bool

Filter is a Pipeline that allows omission of individual lines from streamline.Stream by returning false on lines that should be skipped.

func (Filter) Inactive added in v0.2.0

func (f Filter) Inactive() bool

func (Filter) ProcessLine added in v0.2.0

func (f Filter) ProcessLine(line []byte) ([]byte, error)

type Map

type Map func(line []byte) []byte

Map is a Pipeline that allows modifications of individual lines from streamline.Stream. Implementations can return a nil []byte to indicate a line is to be skipped.

func (Map) Inactive

func (m Map) Inactive() bool

func (Map) ProcessLine

func (m Map) ProcessLine(line []byte) ([]byte, error)

type MultiPipeline

type MultiPipeline []Pipeline

MultiPipeline is a Pipeline that applies all its Pipelines in serial.

func (MultiPipeline) Inactive

func (mp MultiPipeline) Inactive() bool

func (MultiPipeline) ProcessLine

func (mp MultiPipeline) ProcessLine(line []byte) ([]byte, error)

type Pipeline

type Pipeline interface {
	// Inactive indicates if this Pipeline does anything at all. It is used internally by
	// streamline.Stream to optimize for cases where accommodating a Pipeline adds overhead.
	Inactive() bool
	// ProcessLine returns a modified, unmodified, or omitted line. To omit a line, return
	// a nil []byte - an empty []byte will be retained.
	ProcessLine(line []byte) ([]byte, error)
}

Pipeline implementations are used to transform the data provided to a streamline.Stream. For example, they are useful for mapping and pruning data. To configure a Stream to use a Pipeline, use (*Stream).WithPipeline(...).

Note that generally a Pipeline should not be used to implement handling of data - use (*Stream).Stream(...) and (*Stream).StreamBytes(...) instead.

type Sample added in v0.9.0

type Sample struct {
	// N indicates that this Sample pipeline should only retain every Nth line from the
	// output.
	//
	// If set to 0 or 1, this Pipeline is marked as inactive.
	N int
	// contains filtered or unexported fields
}

Sample is a Pipeline that only includes every Nth line from streamline.Stream.

func (*Sample) Inactive added in v0.9.0

func (s *Sample) Inactive() bool

func (*Sample) ProcessLine added in v0.9.0

func (s *Sample) ProcessLine(line []byte) ([]byte, error)

Jump to

Keyboard shortcuts

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