config

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package config reads the configurations from a yaml file and produces necessary configuration for instantiating readers and recorders.

Index

Constants

This section is empty.

Variables

View Source
var EmptyConfigErr = &StructureErr{"", "empty configuration file", nil}

EmptyConfigErr is an error when the config file is empty

Functions

This section is empty.

Types

type Conf

type Conf interface {
	// Endpoint should be a valid URL.
	Endpoint() string

	// Timeout is how long to wait for a response.
	Timeout() time.Duration

	// Backoff returns the amount of retries after the endpoint is rejected
	// the request or not responsive.
	Backoff() int

	// Logger returns an instance of the logger.
	Logger() internal.FieldLogger
}

Conf will return necessary information for setting up readers and recorders.

type ConfMap

type ConfMap struct {
	// Readers contains a map of reader names to their configuration.
	Readers map[string]ReaderConf

	// Recorders contains a map of recorder names to their configuration.
	Recorders map[string]RecorderConf

	// Routes contains a map of recorder names to a list of readers.
	// map["rec1"][]string{"red1", "red2"}: means whatever is read
	// from red1 and red2, will be shipped to rec1.
	Routes map[string][]string
}

ConfMap holds the relation between readers and recorders.

func LoadYAML

func LoadYAML(log *internal.Logger, v *viper.Viper) (*ConfMap, error)

LoadYAML loads the settings from the configuration file. It returns any errors returned from readers/recorders. Please refer to their documentations.

type ErrNotSpecified

type ErrNotSpecified StructureErr

ErrNotSpecified is returned when a section is not specified

func NewErrNotSpecified

func NewErrNotSpecified(section, reason string, err error) *ErrNotSpecified

NewErrNotSpecified instantiates an ErrNotSpecified with the given input

func (*ErrNotSpecified) Error

func (e *ErrNotSpecified) Error() string

type ErrNotSupported

type ErrNotSupported string

ErrNotSupported says something is still not supported

func (ErrNotSupported) Error

func (n ErrNotSupported) Error() string

type ErrRouters

type ErrRouters struct{ StructureErr }

ErrRouters represents an error when routes are not configured correctly. The section on this error is the subsection of the route.

func NewErrRouters

func NewErrRouters(section, reason string, err error) *ErrRouters

NewErrRouters instantiates an ErrRouters with the given input

func (*ErrRouters) Error

func (e *ErrRouters) Error() string

type ReaderConf

type ReaderConf interface {
	Conf

	// Interval is used to signal the reader to fetch the next read.
	Interval() time.Duration

	// NewInstance should return an initialised Reader instance.
	NewInstance() (reader.DataReader, error)

	// TypeName is usually the application name.
	// Readers should not intercept the engine's decision on setting
	// the name, unless they have a valid reason.
	TypeName() string
}

ReaderConf defines a behaviour of a reader.

type RecorderConf

type RecorderConf interface {
	Conf

	// NewInstance should return an initialised Recorder instance.
	NewInstance() (recorder.DataRecorder, error)

	// IndexName comes from the configuration, but the engine might take over.
	// Recorders should not intercept the engine's decision on setting
	// the name, unless they have a valid reason.
	IndexName() string
}

RecorderConf defines a behaviour that requires the recorders to have the concept of Index and Type. If any of these are not applicable, just return an empty string.

type StructureErr

type StructureErr struct {
	Section string // The section that error happened
	Reason  string // The reason behind the error
	Err     error  // Err is the error that occurred during the operation.
}

StructureErr is an error on reading the configuration file.

func (*StructureErr) Error

func (e *StructureErr) Error() string

Error returns "<nil>" if the error is nil.

Jump to

Keyboard shortcuts

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