scroller

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package scroller helps analyzing a continuously written line by line text content, e.g. at the monitoring of log files. Here the Scroller is working in the background and allows to read out of any ReadSeeker (which may be a File) from beginning, end or a given number of lines before the end, filter the output by a filter function and write it into a Writer. If a number of lines and a filter are passed the Scroller tries to find that number of lines matching to the filter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FilterFunc

type FilterFunc func(line []byte) bool

FilterFunc decides if a line shall be scrolled (func is nil or returns true) or not (func returns false).

type Option

type Option func(s *Scroller) error

Option defines a function setting an option.

func BufferSize

func BufferSize(bs int) Option

BufferSize allows to set the initial size of the buffer used for reading.

func Filter

func Filter(ff FilterFunc) Option

Filter sets the filter function of the scroller.

func PollTime

func PollTime(pt time.Duration) Option

PollTime defines the frequency the source is polled.

func Skip

func Skip(l int) Option

Skip sets the number of lines ro skip initially.

type Scroller

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

Scroller scrolls and filters a ReadSeeker line by line and writes the data into a Writer.

func NewScroller

func NewScroller(source io.ReadSeeker, target io.Writer, options ...Option) (*Scroller, error)

NewScroller starts a Scroller for the given source and target. The options can control the number of lines, a filter, the buffer size and the poll time.

func (*Scroller) Err

func (s *Scroller) Err() error

Err returns the status and a possible error of the scroller.

func (*Scroller) Stop

func (s *Scroller) Stop() error

Stop tells the scroller to end working.

func (*Scroller) Wait

func (s *Scroller) Wait() error

Wait makes a caller waiting until the scroller has stopped working.

Jump to

Keyboard shortcuts

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