Documentation
¶
Overview ¶
Package tpack provides tools to package Go workflows as Unix-style pipeline commands.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Packer ¶
type Packer struct {
// contains filtered or unexported fields
}
Packer facilitates writing programs that manipulate text streams, a fundamental concept in the Unix philosophy. It enables seamless data transfer between processes, allowing the output of one process to be used as input for another.
func NewPackerStd ¶
NewPackerStd returns a new Packer that uses the standard input, output, and error streams as communication channels.
func NewPackerStdOut ¶
NewPackerStdOut returns a new Packer that uses the standard output and error streams as output channels and the provided io.Reader as the input communication channel.
type PackerOpt ¶
type PackerOpt func(*packerOpts)
PackerOpt represents a customization option to configure a packer.
func WithErrWriteHandler ¶
WithErrWriteHandler configures a custom error handler for writing to err. The default error handler will panic on an error.
type ProcOpt ¶
type ProcOpt func(*procOpts)
ProcOpt represents a customization option to configure a processor.
func Parallel ¶
Parallel configures the processor parallelism. The specified value is required to be greater than zero. Otherwise, it is ignored. The default parallelism is 1.
Parallel workflows can be useful when the processing order is not important - for further counting or any other type of aggregation command.
type Processor ¶
type Processor interface {
// InChan returns the input communication channel.
InChan() chan []byte
// OutChan returns the output communication channel.
OutChan() chan []byte
// ErrChan returns the error output communication channel.
ErrChan() chan error
}
Processor represents a generic data stream processor.
func NewProcessor ¶
NewProcessor returns a new Processor with the specified transformation function. The transformation function type can be either string or slice of bytes. Additional options can be provided to customize the processor, e.g.
tpack.Parallel(2)
