Documentation
¶
Index ¶
- func ComputeOutputFilename(outputFile string, outputFileTemplate string, row types.Row, index int) (string, error)
- func StartFormatIntoChannel[T interface{ ... }](ctx context.Context, table *types.Table, formatter TableOutputFormatter) <-chan T
- func StartStreamRows[T interface{ ... }](ctx context.Context, formatter RowOutputFormatter) (chan<- types.Row, <-chan T)
- func StreamRows(ctx context.Context, formatter RowOutputFormatter, ...) error
- type RowOutputFormatter
- type TableOutputFormatter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeOutputFilename ¶ added in v0.2.58
func StartFormatIntoChannel ¶ added in v0.2.82
func StartFormatIntoChannel[T interface{ ~string }]( ctx context.Context, table *types.Table, formatter TableOutputFormatter, ) <-chan T
StartFormatIntoChannel outputs the data from an TableOutputFormatter into a channel. This is useful to render a table into a stream, for example when rendering larger outputs into HTML when serving.
func StartStreamRows ¶ added in v0.3.0
func StartStreamRows[T interface{ ~string }]( ctx context.Context, formatter RowOutputFormatter, ) (chan<- types.Row, <-chan T)
StartStreamRows starts a background goroutine that returns two channels. The first channel is used to send rows to the background goroutine, the second channel is used to receive the formatted output.
This background goroutine will close the output channel when it is done.
func StreamRows ¶ added in v0.3.0
Types ¶
type RowOutputFormatter ¶ added in v0.3.0
type TableOutputFormatter ¶
type TableOutputFormatter interface { // RegisterMiddlewares allows individual OutputFormatters to register middlewares that might be // necessary for them to do the proper output. For example, table and excel output require // flattening the row objects before output. // // TODO(manuel, 2023-06-28) We could add the indication if this output formatter can stream here // Not all output formatters should have to take a full table, but could instead output a single row RegisterMiddlewares(mw *middlewares.Processor) error Output(ctx context.Context, table *types.Table, w io.Writer) error ContentType() string }
TableOutputFormatter is an output formatter that requires an entire table to be computed up front before it can be output.
NOTE(manuel, 2023-06-28) Since this is actually the first type of Formatter that was implemented, it is the current de facto standard. RowOutputFormatter has been added later and is thus not in wide spread use.