events

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2014 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseEvent

type BaseEvent struct {
	Ts        int64             `json:"ts"`
	Kind      string            `json:"name"`
	Version   string            `json:"version,omitempty"`
	Endpoints map[string]string `json:"endpoints,omitempty"`
}

BaseEvent is an event that is sent when the pipeline has been started or exited

func NewBootEvent

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

NewBootEvent (surprisingly) creates a new baseEvent

func NewExitEvent

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

NewExitEvent (surprisingly) creates a new BaseEvent

func (*BaseEvent) Emit

func (e *BaseEvent) Emit() ([]byte, error)

Emit prepares the event to be emitted and marshalls the event into an json

func (*BaseEvent) String

func (e *BaseEvent) String() string

String

type Emitter

type Emitter interface {
	Start()
	Init(chan Event)
	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 Init() serves to set the Emitter's listening channel 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

type ErrorEvent

type ErrorEvent struct {
	Ts   int64  `json:"ts"`
	Kind string `json:"name"`
	Path string `json:"path"`

	// Record is the document (if any) that was in progress when the error occured
	Record bson.M `json:"record,omitempty"`

	// Message is the error message as a string
	Message string `json:"message,omitempty"`
}

ErrorEvent is an event that indicates an error occured during the processing of a pipeline

func NewErrorEvent

func NewErrorEvent(ts int64, path string, record bson.M, message string) *ErrorEvent

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

func (*ErrorEvent) Emit

func (e *ErrorEvent) Emit() ([]byte, error)

Emit prepares the event to be emitted and marshalls the event into an json

func (*ErrorEvent) String

func (e *ErrorEvent) String() string

String

type Event

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

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 emittied by each pipe and include a measure of how many messages have been processed

type HTTPPostEmitter

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

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 NewHTTPPostEmitter

func NewHTTPPostEmitter(uri, key, pid string) *HTTPPostEmitter

NewHTTPPostEmitter creates a new HTTPPostEmitter

func (*HTTPPostEmitter) Init

func (e *HTTPPostEmitter) Init(ch chan Event)

Init sets the event channel

func (*HTTPPostEmitter) Start

func (e *HTTPPostEmitter) Start()

Start the emitter

func (*HTTPPostEmitter) Stop

func (e *HTTPPostEmitter) Stop()

Stop sends a stop signal and waits for the inflight posts to complete before exiting

type LogEmitter

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

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 NewLogEmitter

func NewLogEmitter() *LogEmitter

NewLogEmitter creates a new LogEmitter

func (*LogEmitter) Init

func (e *LogEmitter) Init(ch chan Event)

Init sets the event channel

func (*LogEmitter) Start

func (e *LogEmitter) Start()

Start the emitter

func (*LogEmitter) Stop

func (e *LogEmitter) Stop()

Stop the emitter

type MetricsEvent

type MetricsEvent struct {
	Ts   int64  `json:"ts"`
	Kind string `json:"name"`
	Path string `json:"path"`

	// Records indicated the total number of documents that have been transmitted
	Records int `json:"records"`
}

MetricsEvent is an event used to indicated progress.

func NewMetricsEvent

func NewMetricsEvent(ts int64, path string, records int) *MetricsEvent

NewMetricsEvent creates a new metrics event

func (*MetricsEvent) Emit

func (e *MetricsEvent) Emit() ([]byte, error)

Emit prepares the event to be emitted and marshalls the event into an json

func (*MetricsEvent) String

func (e *MetricsEvent) String() string

type NoopEmitter

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

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

func NewNoopEmitter

func NewNoopEmitter() *NoopEmitter

NewNoopEmitter constructs a NoopEmitter to use with a transporter pipeline. a 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

func (*NoopEmitter) Init

func (e *NoopEmitter) Init(ch chan Event)

Init sets the event channel

func (*NoopEmitter) Start

func (e *NoopEmitter) Start()

Start the event consumer

func (*NoopEmitter) Stop

func (e *NoopEmitter) Stop()

Stop the event consumer

Jump to

Keyboard shortcuts

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