elasticsearch

package
v0.8.0 Latest Latest
Warning

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

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

Documentation

Overview

Package elasticsearch contains logic to record data to an elasticsearch index. The data is already sanitised by the data provider.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ESEndpoint  string `mapstructure:"endpoint"`
	ESTimeout   string `mapstructure:"timeout"`
	ESBackoff   int    `mapstructure:"backoff"`
	ESIndexName string `mapstructure:"index_name"`
	// contains filtered or unexported fields
}

Config holds the necessary configuration for setting up an elasticsearch reader endpoint.

func FromViper

func FromViper(v *viper.Viper, log internal.FieldLogger, name, key string) (*Config, error)

FromViper constructs the necessary configuration for bootstrapping the elasticsearch reader

func NewConfig

func NewConfig(log internal.FieldLogger, name string, endpoint string, timeout time.Duration, backoff int, indexName string) (*Config, error)

NewConfig returns errors coming from Viper

func (*Config) Backoff

func (c *Config) Backoff() int

Backoff return the backoff

func (*Config) Endpoint

func (c *Config) Endpoint() string

Endpoint return the endpoint

func (*Config) IndexName

func (c *Config) IndexName() string

IndexName return the index name

func (*Config) Logger

func (c *Config) Logger() internal.FieldLogger

Logger return the logger

func (*Config) Name

func (c *Config) Name() string

Name return the name

func (*Config) NewInstance

func (c *Config) NewInstance(ctx context.Context) (recorder.DataRecorder, error)

NewInstance returns an instance of the elasticsearch recorder

func (*Config) RoutePath

func (c *Config) RoutePath() string

RoutePath return an empty string

func (*Config) Timeout

func (c *Config) Timeout() time.Duration

Timeout return the timeout

type Recorder

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

Recorder contains an elasticsearch client and an index name for recording data It implements DataRecorder interface

func New added in v0.7.0

func New(ctx context.Context, log internal.FieldLogger, name, endpoint, indexName string, timeout time.Duration, backoff int) (*Recorder, error)

New returns an error if it can't create the index It returns and error on the following occasions:

Condition            |  Error
---------------------|-------------
Invalid endpoint     | ErrInvalidEndpoint
backoff < 5          | ErrLowBackoffValue
Empty name           | ErrEmptyName
Invalid IndexName    | ErrInvalidIndexName
Empty IndexName      | ErrEmptyIndexName

func (*Recorder) IndexName added in v0.1.1

func (r *Recorder) IndexName() string

IndexName is the index/database

func (*Recorder) Name

func (r *Recorder) Name() string

Name shows the name identifier for this reader

func (*Recorder) Ping added in v0.7.0

func (r *Recorder) Ping() error

Ping should ping the endpoint and report if was successful. It returns and error on the following occasions:

Condition            |  Error
---------------------|-------------
Unavailable endpoint | ErrEndpointNotAvailable
Ping errors          | Timeout/Ping failed
Index creation       | elasticsearch's errors

func (*Recorder) Record added in v0.6.0

func (r *Recorder) Record(ctx context.Context, job *recorder.Job) error

Record returns an error if the endpoint responds in errors. It stops receiving jobs when the endpoint's absence has exceeded the backoff value. It returns an error if the ping is not called or the endpoint is not responding too many times.

func (*Recorder) Timeout added in v0.1.1

func (r *Recorder) Timeout() time.Duration

Timeout returns the timeout

Jump to

Keyboard shortcuts

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