listeners

package
v0.0.0-...-93f7a3c Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInHighTrafficState is the error returned when the listener is has previously reported that there's high traffic
	ErrInHighTrafficState = errors.New("Already in high traffic state")
	// ErrLowTrafficState is the error returned when the threhold for requests per second hasn't been met
	ErrLowTrafficState = errors.New("Low traffic state")
)

Functions

This section is empty.

Types

type Alert

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

Alert is a Listener that will output summary reports

func NewAlertListener

func NewAlertListener(reqPerSecondThreshold int64) Alert

NewAlertListener returns an Alert listener with the specified requests per second threshold. TODO: Defaults to a 2 minute threshold interval, should this be configurable?

func (*Alert) Report

func (a *Alert) Report() (string, error)

Report returns the summary report during based on what's currently in the logs

func (Alert) Start

func (a Alert) Start(listenChan log.Channel) OutputChannel

Start starts the Alert listener

type Listener

type Listener interface {
	// Start should start listening on the supplied log channel and return an OutputChannel
	// that the caller will listen and typically output that to somewhere
	Start(log.Channel) (recv OutputChannel)
}

Listener is an interface for listening to a log Channel and providing a channel that it will output to

type OutputChannel

type OutputChannel chan string

OutputChannel is a channel that accepts strings.

type Summary

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

Summary is a Listener that will output summary reports

func NewSummaryListener

func NewSummaryListener() Summary

NewSummaryListener returns an Summary listener that will report every 10 seconds TODO: Defaults to a 10 seconds trigger interval, should this be configurable?

func (*Summary) Add

func (s *Summary) Add(line log.Line)

Add appends the line to the log storage

func (*Summary) Report

func (s *Summary) Report() (report SummaryReport, err error)

Report returns the summary report during based on what's currently in the logs

func (Summary) Start

func (s Summary) Start(listenChan log.Channel) OutputChannel

Start starts the Summary listener

type SummaryReport

type SummaryReport struct {
	Section        SummaryReportItem
	MostActiveUser SummaryReportItem
	Error4XX       SummaryReportItem
	Error5XX       SummaryReportItem
}

SummaryReport is the data structure that holds all the information for the report

func (SummaryReport) String

func (sr SummaryReport) String() string

type SummaryReportItem

type SummaryReportItem struct {
	Key   string
	Value int
}

SummaryReportItem ...

Jump to

Keyboard shortcuts

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