golib: github.com/tideland/golib/scroller Index | Files

package scroller

import "github.com/tideland/golib/scroller"

Package scroller of the Tideland Go Library helps analyzing a continuously written line by line 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

Package Files

doc.go errors.go scroller.go

Constants

const (
    ErrNoSource = iota + 1
    ErrNoTarget
    ErrNegativeLines
)

Error codes of the scroller package.

func IsNegativeLinesError Uses

func IsNegativeLinesError(err error) bool

IsNegativeLinesError returns true, if the error shows the setting of a negative number of lines to start with.

func IsNoSourceError Uses

func IsNoSourceError(err error) bool

IsNoSourceError returns true, if the error signals that no source has been passed.

func IsNoTargetError Uses

func IsNoTargetError(err error) bool

IsNoTargetError returns true, if the error signals that no target has been passed.

type FilterFunc Uses

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 Uses

type Option func(s *Scroller) error

Option defines a function setting an option.

func BufferSize Uses

func BufferSize(bs int) Option

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

func Filter Uses

func Filter(ff FilterFunc) Option

Filter sets the filter function of the scroller.

func Lines Uses

func Lines(l int) Option

Lines sets the number of lines ro scroll initially.

func PollTime Uses

func PollTime(pt time.Duration) Option

PollTime defines the frequency the source is polled.

type Scroller Uses

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 Uses

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) Error Uses

func (s *Scroller) Error() (int, error)

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

func (*Scroller) Stop Uses

func (s *Scroller) Stop() error

Stop tells the scroller to end working.

func (*Scroller) Wait Uses

func (s *Scroller) Wait() error

Wait blocks until the scroller has stopped.

Package scroller imports 7 packages (graph). Updated 2018-08-29. Refresh now. Tools for package owners.