Documentation ¶
Index ¶
- Variables
- func AsChannel(iter Iterator, bufferSize ...int) <-chan entries.LogEntry
- func Drain(iter Iterator)
- func Dupe(iter Iterator) (Iterator, Iterator)
- func End() (entries.LogEntry, int, error)
- func Err(err error) (entries.LogEntry, int, error)
- func Fanout(iter Iterator) (Iterator, Iterator)
- func IsEnd(err error) bool
- type Func
- type Iterator
- func Cancellable(ctx context.Context, iter Iterator) Iterator
- func Concat(base, next Iterator) Iterator
- func Cutter(iter Iterator, opt ...entries.CutOpt) Iterator
- func Empty() Iterator
- func Filter(iter Iterator, filter func(entry entries.LogEntry, i int, err error) bool) Iterator
- func FromChannel(_entries <-chan entries.LogEntry) Iterator
- func FromSlice(slice []entries.LogEntry) Iterator
- func Joiner(iter Iterator, startPatterns ...string) Iterator
- func Merge(a, b Iterator) Iterator
- func Reassigner(iter Iterator, spec entries.ReassignSpec) Iterator
- func Tag(iter Iterator, tag string) Iterator
- func Transformer(iter Iterator, spec entries.TransformSpec) Iterator
Constants ¶
This section is empty.
Variables ¶
var (
ErrAtEnd = errors.New("end of iterator")
)
Functions ¶
func AsChannel ¶
AsChannel will create a channel that is populated from the Iterator by a new goroutine. If bufferSize is populated, then the returned channel will be a buffered channel.
func Drain ¶
func Drain(iter Iterator)
Drain will drain all entries from a Iterator in a new goroutine. This can be useful as an error fallback in case of an iteration error to prevent upstream blocking.
func Dupe ¶
Dupe will take control of and branch the duplicate Iterator into two identical iterators. Any LogEntry posted to the source Iterator will be sent to both of the new iterators. This is useful in a case similar to when you want to print messages as well as write them to a file. It's not advised to read from an Iterator that has been passed to Dupe, use one of the returned iterators instead.
Types ¶
type Func ¶
Func provides a quicker way to implement an Iterator. A Func implements Iterator.Next, and implicitly provides a base Iterate implementation.
type Iterator ¶
type Iterator interface { // Next returns the next LogEntry and its offset in the stream. // Should return ErrAtEnd if the end of the stream is reached. Next() (entries.LogEntry, int, error) // Iterate will progress through all LogEntry items in the stream, calling iter for each one along with the offset. // If iter returns ErrAtEnd, then iteration will cease, returning a nil error. // If any other error is returned, then iteration will cease, and the error will be returned. Iterate(iter func(entry entries.LogEntry, i int) error) error }
func Cancellable ¶
Cancellable wraps an iterator and makes it cancellable by context. When the context is cancelled and Next is called, all LogEntries will be forwarded to Drain.
func Empty ¶
func Empty() Iterator
Empty returns an empty Iterator that immediately returns from a call to Iterate.
func Filter ¶
Filter wraps an Iterator with a function that - when it returns true - will allow the return values of Next through. If the wrapped Iterator returns a non-nil error, then all values will be passed through regardless
func FromChannel ¶
FromChannel will create a new Iterator from a channel of entries.LogEntry.
func Joiner ¶
Joiner will traverse an Iterator, returning messages that may be joined based on a set of startPatterns. A start pattern defines what a @message value must look like to be interpreted as the start of a log message. Subsequent messages that do not match this pattern will have their @message field appended to the last start line. If the Iterator starts with a LogEntry with a @message field that doesn't match the startPatterns, it will be added as a start anyway.
func Merge ¶
Merge will take over the passed in iterators and forward all log entries elements to the new Iterator. It's advised not to read from an iterator that has been passed to Merge.
func Reassigner ¶
func Reassigner(iter Iterator, spec entries.ReassignSpec) Iterator
Reassigner runs entries.Reassign on each entry that passes through the Iterator.
func Tag ¶
Tag will set the standard tag field to the value specified in tag. If the standard tag field already exists, then the parameter will be appended with a period separator. A Tag is intended to classify the log information in some way to make it easier to filter for later.
func Transformer ¶
func Transformer(iter Iterator, spec entries.TransformSpec) Iterator
Transformer adds entries.Transform logic to this Iterator.