Documentation ¶
Index ¶
- Variables
- func DummyFormatter(v []byte) []byte
- func IsEmptyPipeInputError(err error) bool
- func MarshalJSON(i Iterator) (line []byte, err error)
- func PeekReader(r *bufio.Reader) error
- type BufioIterator
- type CompositeIterator
- type EmptyIterator
- type FileContentsIterator
- type Filter
- type Formatter
- type FuncIterator
- type InfiniteSliceIterator
- type Iterator
- type OverrideIterator
- type PipeIterator
- type PipeOptions
- type RangeIterator
- type RepeatIterator
- type SliceIterator
- type UntypedIterator
- type Validator
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyPipeInput = errors.New("iterator: empty pipe input")
ErrEmptyPipeInput pipe input is being used but it is empty
var ErrNoPipeInput = errors.New("iterator: no piped input")
ErrNoPipeInput is an error when there is no piped input on standard input
Functions ¶
func DummyFormatter ¶
func IsEmptyPipeInputError ¶
func MarshalJSON ¶
func PeekReader ¶
PeekReader check if the reader contains empty input or not An error will be returned if the reader does not contain any data, or the first character is whitespace
Types ¶
type BufioIterator ¶
type BufioIterator struct {
// contains filtered or unexported fields
}
BufioIterator is a wrapper around a bufio.Reader which conforms to the Iterator interface
func NewBufioIterator ¶
func NewBufioIterator(reader *bufio.Reader) *BufioIterator
NewBufioIterator returns a new iterator from a Bufio reader
func (*BufioIterator) GetNext ¶
func (i *BufioIterator) GetNext() (line []byte, input interface{}, err error)
GetNext returns the next line in the buffer
func (*BufioIterator) IsBound ¶
func (i *BufioIterator) IsBound() bool
IsBound return true if the iterator is bound
func (*BufioIterator) MarshalJSON ¶
func (i *BufioIterator) MarshalJSON() (line []byte, err error)
MarshalJSON return the value in a json compatible value
type CompositeIterator ¶
type CompositeIterator struct {
// contains filtered or unexported fields
}
func NewCompositeStringIterator ¶
func NewCompositeStringIterator(iterator Iterator, format string) *CompositeIterator
NewCompositeStringIterator create a new string iterator built from an already existing iterator
func (*CompositeIterator) GetNext ¶
func (i *CompositeIterator) GetNext() (line []byte, input interface{}, err error)
GetNext will count through the values and return them one by one
func (*CompositeIterator) GetValueByInput ¶
func (i *CompositeIterator) GetValueByInput(input []byte) (line []byte, err error)
func (*CompositeIterator) IsBound ¶
func (i *CompositeIterator) IsBound() bool
IsBound return true if the iterator is bound
type EmptyIterator ¶
type EmptyIterator struct{}
EmptyIterator is an empty iterator that always returns no value
func (*EmptyIterator) GetNext ¶
func (i *EmptyIterator) GetNext() (line []byte, input interface{}, err error)
GetNext always return io.EOF
func (*EmptyIterator) IsBound ¶
func (i *EmptyIterator) IsBound() bool
IsBound return true if the iterator is bound
func (*EmptyIterator) MarshalJSON ¶
func (i *EmptyIterator) MarshalJSON() (line []byte, err error)
MarshalJSON return the value in a json compatible value
type FileContentsIterator ¶
type FileContentsIterator struct {
// contains filtered or unexported fields
}
FileContentsIterator is a wrapper around a bufio.Reader which conforms to the Iterator interface
func (*FileContentsIterator) GetNext ¶
func (i *FileContentsIterator) GetNext() (line []byte, input interface{}, err error)
GetNext returns the next line in the buffer
func (*FileContentsIterator) IsBound ¶
func (i *FileContentsIterator) IsBound() bool
IsBound return true if the iterator is bound
func (*FileContentsIterator) MarshalJSON ¶
func (i *FileContentsIterator) MarshalJSON() (line []byte, err error)
MarshalJSON return the value in a json compatible value
type Filter ¶
Filter is a funciton applied on every iteration. Returning False will end the iterator
type Formatter ¶
Formatter a function to transform input pipeline value and returns the formatted value as output
type FuncIterator ¶
type FuncIterator struct {
// contains filtered or unexported fields
}
FuncIterator is generic iterator which executes a function on every iteration
func NewFuncIterator ¶
func NewFuncIterator(next func(int64) (string, error), n int64) *FuncIterator
NewFuncIterator return an iterator based on the given function
func NewRelativeDateIterator ¶
func NewRelativeDateIterator(relative string, encode bool, layout string, format ...string) *FuncIterator
NewRelativeDateIterator returns a relative date iterator which can generate dates based on time.Now when the value is retrieved
func NewRelativeTimeIterator ¶
func NewRelativeTimeIterator(relative string, encode bool, format ...string) *FuncIterator
NewRelativeTimeIterator returns a relative time iterator which can generate timestamps based on time.Now when the value is retrieved
func (*FuncIterator) GetNext ¶
func (i *FuncIterator) GetNext() (line []byte, input interface{}, err error)
GetNext will count through the values and return them one by one
func (*FuncIterator) IsBound ¶
func (i *FuncIterator) IsBound() bool
IsBound return true if the iterator is bound
func (*FuncIterator) MarshalJSON ¶
func (i *FuncIterator) MarshalJSON() (line []byte, err error)
MarshalJSON return the value in a json compatible value
type InfiniteSliceIterator ¶
type InfiniteSliceIterator struct {
SliceIterator
}
InfiniteSliceIterator is iterates over a given array and once the last element is return, it sets the index back to the first element. It will continue indefinitely
func NewInfiniteSliceIterator ¶
func NewInfiniteSliceIterator(values []string) *InfiniteSliceIterator
NewInfiniteSliceIterator creates a repeater which returns the slice items and wraps around indefinitely
func (*InfiniteSliceIterator) GetNext ¶
func (i *InfiniteSliceIterator) GetNext() (line []byte, input interface{}, err error)
GetNext will count through the values and return them one by one
type Iterator ¶
type Iterator interface { GetNext() (line []byte, input interface{}, err error) // IsBound return true if the iterator is bound IsBound() bool }
Iterator is a simple interfact where the next value can be returned.
func NewFileContentsIterator ¶
NewFileContentsIterator returns a file contents iterator
func NewJSONPipeIterator ¶
NewJSONPipeIterator returns a new pipe iterator
type OverrideIterator ¶
type OverrideIterator struct { OverrideValue Iterator // contains filtered or unexported fields }
func NewOverrideIterator ¶
func NewOverrideIterator(valueIterator Iterator, overrideValue Iterator) *OverrideIterator
NewOverrideIterator create a new iterator which can be override with other values
func (*OverrideIterator) GetNext ¶
func (i *OverrideIterator) GetNext() (value []byte, input interface{}, err error)
func (*OverrideIterator) IsBound ¶
func (i *OverrideIterator) IsBound() bool
IsBound return true if the iterator is bound
func (*OverrideIterator) MarshalJSON ¶
func (i *OverrideIterator) MarshalJSON() (line []byte, err error)
MarshalJSON return the value in a json compatible value
type PipeIterator ¶
type PipeIterator struct {
// contains filtered or unexported fields
}
PipeIterator is a thread safe iterator to retrieve the input values from piped standard input
func (*PipeIterator) GetNext ¶
func (i *PipeIterator) GetNext() (line []byte, input interface{}, err error)
GetNext returns the next line from the pipeline
func (*PipeIterator) IsBound ¶
func (i *PipeIterator) IsBound() bool
IsBound return true if the iterator is bound
func (*PipeIterator) MarshalJSON ¶
func (i *PipeIterator) MarshalJSON() (line []byte, err error)
MarshalJSON return the value in a json compatible value
type PipeOptions ¶
type PipeOptions struct { // Property name if the input data is json Properties []string // AllowEmpty allow pipeline items without any matching properties. AllowEmpty bool // Validator to be applied on each item Validator Validator // Formatter Formatter Formatter }
PipeOptions additional options on how to interpret the piped data
type RangeIterator ¶
type RangeIterator struct {
// contains filtered or unexported fields
}
RangeIterator returns value sequentially from start to end
func NewRangeIterator ¶
func NewRangeIterator(start, end, step int64) *RangeIterator
NewRangeIterator creates a new range iterator to step through values from a start to end with step
func (*RangeIterator) GetNext ¶
func (i *RangeIterator) GetNext() (line []byte, input interface{}, err error)
GetNext returns the next value from the range
func (*RangeIterator) IsBound ¶
func (i *RangeIterator) IsBound() bool
IsBound return true if the iterator is bound
func (*RangeIterator) MarshalJSON ¶
func (i *RangeIterator) MarshalJSON() (line []byte, err error)
MarshalJSON return the value in a json compatible value
type RepeatIterator ¶
type RepeatIterator struct {
// contains filtered or unexported fields
}
RepeatIterator is an empty iterator that always returns no value
func NewRepeatIterator ¶
func NewRepeatIterator(value string, n int64) *RepeatIterator
NewRepeatIterator creates a repeater which returns the same value n times before returns io.EOF. If n is set to 0, then it will repeat forever
func (*RepeatIterator) GetNext ¶
func (i *RepeatIterator) GetNext() (line []byte, input interface{}, err error)
GetNext will count through the values and return them one by one
func (*RepeatIterator) IsBound ¶
func (i *RepeatIterator) IsBound() bool
IsBound return true if the iterator is bound
func (*RepeatIterator) MarshalJSON ¶
func (i *RepeatIterator) MarshalJSON() (line []byte, err error)
MarshalJSON return the value in a json compatible value
type SliceIterator ¶
type SliceIterator struct {
// contains filtered or unexported fields
}
SliceIterator is iterates over a given array
func NewSliceIterator ¶
func NewSliceIterator(values []string, format ...string) *SliceIterator
NewSliceIterator creates a repeater which returns the slice items before returns io.EOF
func (*SliceIterator) GetNext ¶
func (i *SliceIterator) GetNext() (line []byte, input interface{}, err error)
GetNext will count through the values and return them one by one
func (*SliceIterator) IsBound ¶
func (i *SliceIterator) IsBound() bool
IsBound return true if the iterator is bound
func (*SliceIterator) MarshalJSON ¶
func (i *SliceIterator) MarshalJSON() (line []byte, err error)
MarshalJSON return the value in a json compatible value
type UntypedIterator ¶
type UntypedIterator interface {
GetNext() (out interface{}, err error)
}