harvester

package
v2.0.5+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLineTooLong is returned when the read line was longer than the maximum
	// allowed buffered length
	ErrLineTooLong = errors.New("LineReader: line too long")
)
View Source
var (
	// Stdin is the filename that represents stdin
	Stdin = "stdin"
)

Functions

This section is empty.

Types

type FinishStatus

type FinishStatus struct {
	LastEventOffset int64
	LastReadOffset  int64
	Error           error
	LastStat        os.FileInfo
}

FinishStatus contains the final file state, and any errors, from the point the harvester finished

type Harvester

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

Harvester reads from a file, passes lines through a codec, and sends them for spooling

func NewHarvester

func NewHarvester(stream core.Stream, config *config.Config, streamConfig *config.Stream, offset int64) *Harvester

NewHarvester creates a new harvester with the given configuration for the given stream identifier

func (*Harvester) APIEncodable

func (h *Harvester) APIEncodable() admin.APIEncodable

APIEncodable returns an admin API entry with harvester status

func (*Harvester) OnFinish

func (h *Harvester) OnFinish() <-chan *FinishStatus

OnFinish returns a channel which will receive a FinishStatus structure when the harvester stops

func (*Harvester) Start

func (h *Harvester) Start(output chan<- *core.EventDescriptor)

Start runs the harvester, sending events to the output given, and returns immediately

func (*Harvester) Stop

func (h *Harvester) Stop()

Stop requests the harvester to stop

type LineReader

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

LineReader is a read interface that tails and returns lines

func NewLineReader

func NewLineReader(rd io.Reader, size int, maxLine int) *LineReader

NewLineReader creates a new line reader structure reading from the given io.Reader with the given size buffer and the given maximum line size If a line exceeds the maxmium line size it will be cut into segments, see ReadSlice. If the maximum line size is greater than the given buffer size, lines that are larger than the buffer will overflow into additional memory allocations. Therefore, the buffer size should be sized to handle the most common line lengths.

func (*LineReader) BufferedLen

func (lr *LineReader) BufferedLen() int

BufferedLen returns the current number of bytes sitting in the buffer awaiting a new line

func (*LineReader) ReadSlice

func (lr *LineReader) ReadSlice() ([]byte, error)

ReadSlice returns a line as a byte slice Returns ErrLineTooLong if the line was cut short because it was longer than the maximum line length allowed. Subsequent returned lines will be a continuation of the cut line, with the final segment returning nil error

func (*LineReader) Reset

func (lr *LineReader) Reset()

Reset the linereader, still using the same io.Reader, but as if it had just being constructed. This will cause any currently buffered data to be lost

Jump to

Keyboard shortcuts

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