report

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2016 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package report implements reporting support around watchable source.DataSource.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FormattedReporter

type FormattedReporter interface {
	source.ItemWatcher
	Source() source.DataSource
	Start() error
	Stop()
}

FormattedReporter reports observed items from a data source to a formatting function. Only works with sources that support the "text" format.

For example to send a source to stdandard output:

rep := NewPrintfReporter(someSource, fmt.Printf)
if err := rep.Start(); err != nil {
    panic(err)
}
defer rep.Stop()

func NewLogfReporter

func NewLogfReporter(
	src source.DataSource,
	logf func(format string, args ...interface{}),
) FormattedReporter

NewLogfReporter creates a FormattedReporter around a log formatting function. Log formatting functions are not expected to return an error, and are expected to handle their own framing concerns (e.g. adding a trailing newline).

func NewPrintfReporter

func NewPrintfReporter(
	src source.DataSource,
	printf func(format string, args ...interface{}) (int, error),
) FormattedReporter

NewPrintfReporter creates a new FormattedReporter around a raw fmt.Printf-family formatting function. The formatting function is expected to return a number and error in package fmt style. NewPrintfReporter will append a newline to passed format strings, since the print formatting function is expected to not do so.

Jump to

Keyboard shortcuts

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