text

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilReader = errors.New("nil io.Reader provided to TextReader")
)

ErrNilReader is returned when a nil io.Reader interface is provided

View Source
var ErrNilWriter = errors.New("nil io.Writer provided to TextWriter")

ErrNilWriter returned when a nil io.Writer is provided

Functions

This section is empty.

Types

type Reader

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

Reader a worker that read data from an io.Reader

func NewReader

func NewReader(opts ReaderOptions) *Reader

NewReader create a new Reader with given options

func (*Reader) Process

func (t *Reader) Process(ctx context.Context, args selina.ProcessArgs) (err error)

Process implements Worker interface

type ReaderOptions

type ReaderOptions struct {
	// Reader from which data is readed
	Reader io.Reader
	// AutoClose if its true and Reader implements io.Closer
	// io.Reader.Close() method is called on Process finish
	AutoClose bool
	// Default is ScanLines
	SplitFunc bufio.SplitFunc
	// ReadFormat process every data point with this function
	// default is nil , raw message is passed to WriteFormat
	ReadFormat selina.Unmarshaler
	// WriteFormat by default is json.Marshal
	WriteFormat selina.Marshaler
}

ReaderOptions customize Reader

func (ReaderOptions) Check added in v0.8.0

func (o ReaderOptions) Check() error

Check if a combination of options is valid

type Writer

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

Writer a Worker that write data to a given io.Writer in text format

func NewWriter

func NewWriter(opts WriterOptions) *Writer

NewWriter create a new Writer with given options

func (*Writer) Process

func (t *Writer) Process(ctx context.Context, args selina.ProcessArgs) (err error)

Process implements Worker interface

type WriterOptions

type WriterOptions struct {
	// Writer io.Writer where data will be written
	Writer io.Writer
	// AutoClose when true and Writer implements io.Closer
	// io.Closer.Close() method will be called on finalization
	AutoClose   bool
	SkipNewLine bool
	BufferSize  int
	Codec       selina.Marshaler
}

WriterOptions customize Writer

func (WriterOptions) Check added in v0.8.0

func (o WriterOptions) Check() error

Check if a combination of options is valid

Jump to

Keyboard shortcuts

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