reader

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2017 License: Apache-2.0 Imports: 5 Imported by: 10

Documentation

Overview

Package reader contains logic for reading from a provider. Any objects that implements the DataReader interface can be used in this system. The job should provide an io.ReadCloser and should produce a JSON object, otherwise the data will be rejected.

The data stream SHOULD not be closed. The engine WILL close it upon reading its contents.

Readers should ping their endpoint upon creation to make sure they can read from. Otherwise they should return an error indicating they cannot start.

When the context is cancelled, the reader should finish its job and return. The Time should be set when the data is read from the endpoint, otherwise it will lose its meaning. The engine will issue jobs based on the Interval, which is set in the configuration file.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyName is the error when the package name is empty.
	ErrEmptyName = fmt.Errorf("name cannot be empty")

	// ErrEmptyEndpoint is the error when the given endpoint is empty.
	ErrEmptyEndpoint = fmt.Errorf("endpoint cannot be empty")

	// ErrEmptyTypeName is the error when the type_name is an empty string.
	ErrEmptyTypeName = fmt.Errorf("type_name cannot be empty")

	// ErrBackoffExceeded is the error when the endpoint's absence has exceeded the backoff value.
	// It is not strictly an error, it is however a pointer to an error in the past.
	ErrBackoffExceeded = fmt.Errorf("endpoint gone too long")
)

Functions

This section is empty.

Types

type DataReader added in v0.1.2

type DataReader interface {
	// Name should return the representation string for this reader. Choose a very simple and unique name.
	Name() string

	// When the context is timed-out or cancelled, the reader should return.
	Read(context.Context) (*ReadJobResult, error)

	// Mapper should return an instance of the datatype mapper.
	// Engine uses this object to present the data to recorders.
	Mapper() datatype.Mapper

	// TypeName is usually the application name and is set by the user in the configuration file.
	// Recorders should not intercept the engine for its decision, unless they have a
	// valid reason.
	TypeName() string

	// Timeout is required by the Engine so it can read the time-outs.
	Timeout() time.Duration

	// Interval is required by the Engine so it can read the intervals.
	Interval() time.Duration
}

DataReader receives job requests to read from the target, and sends its success through the ResultChan channel.

type ErrEndpointNotAvailable added in v0.5.0

type ErrEndpointNotAvailable struct {
	Endpoint string
	Err      error
}

ErrEndpointNotAvailable is the error when the endpoint is not available.

func (ErrEndpointNotAvailable) EndpointNotAvailable added in v0.5.0

func (ErrEndpointNotAvailable) EndpointNotAvailable()

EndpointNotAvailable defines the behaviour of the error

func (ErrEndpointNotAvailable) Error added in v0.5.0

func (e ErrEndpointNotAvailable) Error() string

type ErrInvalidEndpoint added in v0.5.0

type ErrInvalidEndpoint string

ErrInvalidEndpoint is the error when the endpoint is not a valid url

func (ErrInvalidEndpoint) Error added in v0.5.0

func (e ErrInvalidEndpoint) Error() string

func (ErrInvalidEndpoint) InvalidEndpoint added in v0.5.0

func (ErrInvalidEndpoint) InvalidEndpoint()

InvalidEndpoint defines the behaviour of the error

type ErrLowBackoffValue added in v0.6.0

type ErrLowBackoffValue int64

ErrLowBackoffValue is the error when the endpoint is not a valid url

func (ErrLowBackoffValue) Error added in v0.6.0

func (e ErrLowBackoffValue) Error() string

func (ErrLowBackoffValue) LowBackoffValue added in v0.6.0

func (ErrLowBackoffValue) LowBackoffValue()

LowBackoffValue defines the behaviour of the error

type ReadJobResult

type ReadJobResult struct {
	ID       communication.JobID
	Time     time.Time
	TypeName string
	Res      []byte
	Mapper   datatype.Mapper //TODO: refactor this out
}

ReadJobResult is constructed every time a new record is fetched. The time is set after the request was successfully read.

Directories

Path Synopsis
Package expvar contains logic to read from an expvar provide.
Package expvar contains logic to read from an expvar provide.
Package self contains codes for recording expvastic's own metrics.
Package self contains codes for recording expvastic's own metrics.

Jump to

Keyboard shortcuts

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