emitters

package
v0.1.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChanEmitter

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

ChanEmitter is an emitter that takes in a channel and and sets it up as the source of the emitter .

func Chan

func Chan(channel interface{}) *ChanEmitter

Chan creates new slice source

func (*ChanEmitter) GetOutput

func (c *ChanEmitter) GetOutput() <-chan interface{}

GetOutput returns the output channel of this source node

func (*ChanEmitter) Open

func (c *ChanEmitter) Open(ctx context.Context) error

Open opens the source node to start streaming data on its channel

type CsvEmitter

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

CsvEmitter implements an Emitter node that gets its content from the specified io.Reader and emits each record as []string.

func CSV

func CSV(source interface{}) *CsvEmitter

CSV creates a new CsvEmitter. If the source parameter is a string, it attempts to open a file with that name. If source is an io.Reader, it sources from the reader directly. Any other source type will cause an error.

func (*CsvEmitter) CommentChar

func (c *CsvEmitter) CommentChar(char rune) *CsvEmitter

CommentChar sets the character used to indicate comment lines

func (*CsvEmitter) DelimChar

func (c *CsvEmitter) DelimChar(char rune) *CsvEmitter

Delimiter sets the delimiter character to use (default is comma)

func (*CsvEmitter) GetOutput

func (c *CsvEmitter) GetOutput() <-chan interface{}

GetOutput returns the channel for the source

func (*CsvEmitter) HasHeaders

func (c *CsvEmitter) HasHeaders() *CsvEmitter

HasHeaders indicates that data source has header record

func (*CsvEmitter) Open

func (c *CsvEmitter) Open(ctx context.Context) (err error)

Open starting point that opens the source to start emitting data

type ReaderEmitter

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

ReaderEmitter takes an io.Reader as its source and emits a slice of bytes, N length, with each iteration.

func Reader

func Reader(reader io.Reader) *ReaderEmitter

Reader returns a *ReaderEmitter which can be used to emit bytes

func (*ReaderEmitter) BufferSize

func (e *ReaderEmitter) BufferSize(s int) *ReaderEmitter

BufferSize sets the size of the transfer buffer used to read from the source io.Reader.

func (*ReaderEmitter) GetOutput

func (e *ReaderEmitter) GetOutput() <-chan interface{}

GetOutput returns the output channel of this source node

func (*ReaderEmitter) Open

func (e *ReaderEmitter) Open(ctx context.Context) error

Open opens the emitter to start emitting data

type ScannerEmitter

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

ScannerEmitter takes an io.Reader as its source and emits and wraps it into a bufio.Scanner. The scanner tokenizes the source data using the splitter func of type bufio.SplitFunc and emits each token as []byte.

func Scanner

func Scanner(reader io.Reader, splitter bufio.SplitFunc) *ScannerEmitter

Scanner returns a *ScannerEmitter that wraps io.Reader into a bufio.Scanner. The SplitFunc is used to tokenize the IO stream. The text value of the token is sent downstream. bufio.ScanLines will be used by default if none is provided.

func (*ScannerEmitter) GetOutput

func (e *ScannerEmitter) GetOutput() <-chan interface{}

GetOutput returns the output channel of this source node

func (*ScannerEmitter) Open

func (e *ScannerEmitter) Open(ctx context.Context) error

Open opens the emitter to start emitting data

type SliceEmitter

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

SliceEmitter is an emitter that takes in a slice and emits slice items individually as a stream.

func Slice

func Slice(slice interface{}) *SliceEmitter

SliceSrc creates new slice source

func (*SliceEmitter) GetOutput

func (s *SliceEmitter) GetOutput() <-chan interface{}

GetOuptut returns the output channel of this source node

func (*SliceEmitter) Open

func (s *SliceEmitter) Open(ctx context.Context) error

Open opens the source node to start streaming data on its channel

Jump to

Keyboard shortcuts

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