processors

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatRaw = "{{.RawContent}}"
)

Variables

View Source
var Formatters map[string]Formatter

Holds the registered formatters

Functions

func Csv

func Csv(writer io.Writer, countMap map[string]EntryCount)

A formatter for CSV output

func Default

func Default(writer io.Writer, countMap map[string]EntryCount)

The default formatter

func Json

func Json(writer io.Writer, countMap map[string]EntryCount)

A formatter for json output

func Process

func Process(in <-chan *domain.Entry, out chan<- bool, processor Processor)

Process every entry from the input channel and tells the output channel about the end of the process

Types

type CountProcessor

type CountProcessor struct {
	Counters map[string]EntryCount
	// contains filtered or unexported fields
}

Defines a processor for counting entries

func NewCountProcessor

func NewCountProcessor(groups []string, formatter Formatter, writer io.Writer) CountProcessor

Creates a new processor that will count the entries and prints the total at the end of the process groups: an array of the groups to count (level, category, origin or exception) formatter: the component for printing the output in some format writer: the writer that will receive the output for printing

func (CountProcessor) After

func (processor CountProcessor) After()

Prints the totals after the process

func (CountProcessor) Before

func (processor CountProcessor) Before()

func (CountProcessor) Execute

func (processor CountProcessor) Execute(entry *domain.Entry)

Counts the entries as they arrive on the pipeline

type EntryCount

type EntryCount struct {

	// The counter grouped by values
	Values map[string]int64
	// contains filtered or unexported fields
}

Structure that represents a counter

type Formatter

type Formatter func(writer io.Writer, countMap map[string]EntryCount)

Defines a Formatter as a function that prints the given count map on the given writer

func TemplateFormatter

func TemplateFormatter(templateString string) Formatter

Returns a new formatter that uses the given go template for printing the count map

type Processor

type Processor interface {

	// Do something before the entire process
	Before()
	// Process the given entry
	Execute(entry *domain.Entry)
	// Do something after the entire process
	After()
}

Interface that defines an entry processor

func NewPrintProcessor

func NewPrintProcessor(writer io.Writer, format string) Processor

Returns a new processor that will use the given template for formatting the output

Jump to

Keyboard shortcuts

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