output

package
v6.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2024 License: BSD-2-Clause Imports: 14 Imported by: 0

README

Logic for formatting output records as strings to standard output.

There is one record-writer type per supported output file format, and a factory method.

Documentation

Overview

Package output contains logic for formatting output records as strings to standard output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChannelWriter

func ChannelWriter(
	writerChannel <-chan *list.List,
	recordWriter IRecordWriter,
	writerOptions *cli.TWriterOptions,
	doneChannel chan<- bool,
	dataProcessingErrorChannel chan<- bool,
	bufferedOutputStream *bufio.Writer,
	outputIsStdout bool,
)

Types

type FileOutputHandler

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

================================================================

func NewFileAppendOutputHandler

func NewFileAppendOutputHandler(
	filename string,
	recordWriterOptions *cli.TWriterOptions,
) (*FileOutputHandler, error)

func NewFileOutputHandler

func NewFileOutputHandler(
	filename string,
	recordWriterOptions *cli.TWriterOptions,
	doAppend bool,
) (*FileOutputHandler, error)

----------------------------------------------------------------

func NewFileWriteOutputHandler

func NewFileWriteOutputHandler(
	filename string,
	recordWriterOptions *cli.TWriterOptions,
) (*FileOutputHandler, error)

func NewPipeWriteOutputHandler

func NewPipeWriteOutputHandler(
	commandString string,
	recordWriterOptions *cli.TWriterOptions,
) (*FileOutputHandler, error)

func (*FileOutputHandler) Close

func (handler *FileOutputHandler) Close() (retval error)

----------------------------------------------------------------

func (*FileOutputHandler) WriteRecordAndContext

func (handler *FileOutputHandler) WriteRecordAndContext(
	outrecAndContext *types.RecordAndContext,
) error

----------------------------------------------------------------

func (*FileOutputHandler) WriteString

func (handler *FileOutputHandler) WriteString(outputString string) error

----------------------------------------------------------------

type IRecordWriter

type IRecordWriter interface {
	Write(
		outrec *mlrval.Mlrmap,
		context *types.Context,
		bufferedOutputStream *bufio.Writer,
		outputIsStdout bool,
	) error
}

IRecordWriter is the abstract interface for all record-writers. They are specific to output file format, e.g. CSV, PPRINT, JSON, etc.

Convention: nil outrec signifies end of record stream.

The ChannelWriter will call bufferedOutputStream.Flush() after every record if the --fflush flag (writerOptions.FlushOnEveryRecord) is present, so each writer does not have to -- unless the writer retains records e.g. for PPRINT format.

func Create

func Create(writerOptions *cli.TWriterOptions) (IRecordWriter, error)

type MultiOutputHandlerManager

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

================================================================

func NewFileAppendHandlerManager

func NewFileAppendHandlerManager(
	recordWriterOptions *cli.TWriterOptions,
) *MultiOutputHandlerManager

func NewFileOutputHandlerManager

func NewFileOutputHandlerManager(
	recordWriterOptions *cli.TWriterOptions,
	doAppend bool,
) *MultiOutputHandlerManager

----------------------------------------------------------------

func NewFileWritetHandlerManager

func NewFileWritetHandlerManager(
	recordWriterOptions *cli.TWriterOptions,
) *MultiOutputHandlerManager

func NewPipeWriteHandlerManager

func NewPipeWriteHandlerManager(
	recordWriterOptions *cli.TWriterOptions,
) *MultiOutputHandlerManager

func NewStderrWriteHandlerManager

func NewStderrWriteHandlerManager(
	recordWriterOptions *cli.TWriterOptions,
) *MultiOutputHandlerManager

func NewStdoutWriteHandlerManager

func NewStdoutWriteHandlerManager(
	recordWriterOptions *cli.TWriterOptions,
) *MultiOutputHandlerManager

func (*MultiOutputHandlerManager) Close

func (manager *MultiOutputHandlerManager) Close() []error

func (*MultiOutputHandlerManager) WriteRecordAndContext

func (manager *MultiOutputHandlerManager) WriteRecordAndContext(
	outrecAndContext *types.RecordAndContext,
	filename string,
) error

func (*MultiOutputHandlerManager) WriteString

func (manager *MultiOutputHandlerManager) WriteString(
	outputString string,
	filename string,
) error

----------------------------------------------------------------

type OutputHandler

type OutputHandler interface {
	WriteString(outputString string) error
	WriteRecordAndContext(outrecAndContext *types.RecordAndContext) error
	Close() error
}

type OutputHandlerManager

type OutputHandlerManager interface {

	// For print-variants and dump-variants
	WriteString(outputString string, filename string) error

	// For emit-variants and tee
	WriteRecordAndContext(outrecAndContext *types.RecordAndContext, filename string) error

	Close() []error
}

================================================================

type RecordWriterCSV

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

func NewRecordWriterCSV

func NewRecordWriterCSV(writerOptions *cli.TWriterOptions) (*RecordWriterCSV, error)

func (*RecordWriterCSV) Write

func (writer *RecordWriterCSV) Write(
	outrec *mlrval.Mlrmap,
	_ *types.Context,
	bufferedOutputStream *bufio.Writer,
	outputIsStdout bool,
) error

func (*RecordWriterCSV) WriteCSVRecordMaybeColorized

func (writer *RecordWriterCSV) WriteCSVRecordMaybeColorized(
	record []string,
	bufferedOutputStream *bufio.Writer,
	outputIsStdout bool,
	isKey bool,
	quoteAll bool,
) error

type RecordWriterCSVLite

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

func NewRecordWriterCSVLite

func NewRecordWriterCSVLite(writerOptions *cli.TWriterOptions) (*RecordWriterCSVLite, error)

func (*RecordWriterCSVLite) Write

func (writer *RecordWriterCSVLite) Write(
	outrec *mlrval.Mlrmap,
	_ *types.Context,
	bufferedOutputStream *bufio.Writer,
	outputIsStdout bool,
) error

type RecordWriterDKVP

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

func NewRecordWriterDKVP

func NewRecordWriterDKVP(writerOptions *cli.TWriterOptions) (*RecordWriterDKVP, error)

func (*RecordWriterDKVP) Write

func (writer *RecordWriterDKVP) Write(
	outrec *mlrval.Mlrmap,
	_ *types.Context,
	bufferedOutputStream *bufio.Writer,
	outputIsStdout bool,
) error

type RecordWriterJSON

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

----------------------------------------------------------------

func NewRecordWriterJSON

func NewRecordWriterJSON(writerOptions *cli.TWriterOptions) (*RecordWriterJSON, error)

----------------------------------------------------------------

func (*RecordWriterJSON) Write

func (writer *RecordWriterJSON) Write(
	outrec *mlrval.Mlrmap,
	context *types.Context,
	bufferedOutputStream *bufio.Writer,
	outputIsStdout bool,
) error

----------------------------------------------------------------

type RecordWriterMarkdown

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

func NewRecordWriterMarkdown

func NewRecordWriterMarkdown(writerOptions *cli.TWriterOptions) (*RecordWriterMarkdown, error)

func (*RecordWriterMarkdown) Write

func (writer *RecordWriterMarkdown) Write(
	outrec *mlrval.Mlrmap,
	_ *types.Context,
	bufferedOutputStream *bufio.Writer,
	outputIsStdout bool,
) error

----------------------------------------------------------------

type RecordWriterNIDX

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

func NewRecordWriterNIDX

func NewRecordWriterNIDX(writerOptions *cli.TWriterOptions) (*RecordWriterNIDX, error)

func (*RecordWriterNIDX) Write

func (writer *RecordWriterNIDX) Write(
	outrec *mlrval.Mlrmap,
	_ *types.Context,
	bufferedOutputStream *bufio.Writer,
	outputIsStdout bool,
) error

type RecordWriterPPRINT

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

func NewRecordWriterPPRINT

func NewRecordWriterPPRINT(writerOptions *cli.TWriterOptions) (*RecordWriterPPRINT, error)

func (*RecordWriterPPRINT) Write

func (writer *RecordWriterPPRINT) Write(
	outrec *mlrval.Mlrmap,
	_ *types.Context,
	bufferedOutputStream *bufio.Writer,
	outputIsStdout bool,
) error

----------------------------------------------------------------

type RecordWriterTSV

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

func NewRecordWriterTSV

func NewRecordWriterTSV(writerOptions *cli.TWriterOptions) (*RecordWriterTSV, error)

func (*RecordWriterTSV) Write

func (writer *RecordWriterTSV) Write(
	outrec *mlrval.Mlrmap,
	_ *types.Context,
	bufferedOutputStream *bufio.Writer,
	outputIsStdout bool,
) error

type RecordWriterXTAB

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

func NewRecordWriterXTAB

func NewRecordWriterXTAB(writerOptions *cli.TWriterOptions) (*RecordWriterXTAB, error)

func (*RecordWriterXTAB) Write

func (writer *RecordWriterXTAB) Write(
	outrec *mlrval.Mlrmap,
	_ *types.Context,
	bufferedOutputStream *bufio.Writer,
	outputIsStdout bool,
) error

Jump to

Keyboard shortcuts

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