events

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: BSD-3-Clause Imports: 6 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BadStatusError

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

BadStatusError wraps the underlying error when the provided is not parsable time.ParseDuration

func (BadStatusError) Error

func (e BadStatusError) Error() string

type EmitFunc

type EmitFunc func(Event) error

EmitFunc is a function that takes an Event as input and emits it

func HTTPPostEmitter

func HTTPPostEmitter(uri, key, pid string) EmitFunc

HTTPPostEmitter listens on the event channel and posts the events to an http server Events are serialized into json, and sent via a POST request to the given Uri http errors are logged as warnings to the console, and won't stop the Emitter

func JSONLogEmitter

func JSONLogEmitter() EmitFunc

JSONLogEmitter constructs a LogEmitter to use with a transporter pipeline. A JsonLogEmitter listens on the event channel and uses go's fmt package to emit the event, eg. {"ts":1436889121,"name":"metrics","path":"source-development.jobs/dest-x.jobs","records":121} {"ts":1436889121,"name":"exit","version":"0.0.4","endpoints":{"dest-x.jobs":"mongo","source-development.jobs":"mongo"}}

func LogEmitter

func LogEmitter() EmitFunc

LogEmitter constructs a LogEmitter to use with a transporter pipeline. A LogEmitter listens on the event channel and uses go's log package to emit the event, eg.

2014/11/28 16:56:58 boot map[source:mongo out:mongo]
2014/11/28 16:56:58 metrics source recordsIn: 0, recordsOut: 203
2014/11/28 16:56:58 exit
2014/11/28 16:56:58 metrics source/out recordsIn: 203, recordsOut: 0

func NoopEmitter

func NoopEmitter() EmitFunc

NoopEmitter consumes the events from the listening channel and does nothing with them this is useful for cli utilities that dump output to stdout in any case, and don't want to clutter the program's output with metrics

type Emitter

type Emitter interface {
	Start()
	Stop()
}

Emitter types are used by the transporter pipeline to consume events from a pipeline's event channel and process them. Start() will start the emitter and being consuming events Stop() stops the event loop and releases any resources. Stop is expected to shut down the process cleanly, the pipeline process will block until Stop() returns

func NewEmitter

func NewEmitter(listen chan Event, emit EmitFunc) Emitter

NewEmitter creates a new emitter that will listen on the listen channel and use the emit EmitFunc to process events

type Event

type Event interface {
	Emit() ([]byte, error)
	String() string
	Logger() log.Logger
}

Event is an interface that describes data which is produced periodically by the running transporter.

Events come in multiple kinds. BaseEvents are emitted when the transporter starts and stops, metricsEvents are emitted by each pipe and include a measure of how many messages have been processed

func NewBootEvent

func NewBootEvent(ts int64, version string, endpoints map[string]string) Event

NewBootEvent (surprisingly) creates a new BaseEvent

func NewErrorEvent

func NewErrorEvent(ts int64, path string, record interface{}, message string) Event

NewErrorEvent are events sent to indicate a problem processing on one of the nodes

func NewExitEvent

func NewExitEvent(ts int64, version string, endpoints map[string]string) Event

NewExitEvent (surprisingly) creates a new BaseEvent

func NewMetricsEvent

func NewMetricsEvent(ts int64, path string, records int) Event

NewMetricsEvent creates a new metrics event

Jump to

Keyboard shortcuts

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