elasticsearch

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2018 License: Apache-2.0 Imports: 10 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 Conf added in v0.9.1

type Conf func(*Config) error

Conf func is used for initializing a Config object.

func WithBackoff added in v0.9.1

func WithBackoff(backoff int) Conf

WithBackoff doesn't produce any errors.

func WithEndpoint added in v0.9.1

func WithEndpoint(endpoint string) Conf

WithEndpoint produces an error if endpoint is empty.

func WithIndexName added in v0.9.1

func WithIndexName(indexName string) Conf

WithIndexName produces an error if indexName is empty.

func WithLogger added in v0.9.1

func WithLogger(log internal.FieldLogger) Conf

WithLogger produces an error if the log is nil.

func WithName added in v0.9.1

func WithName(name string) Conf

WithName produces an error if name is empty.

func WithTimeout added in v0.9.1

func WithTimeout(timeout time.Duration) Conf

WithTimeout doesn't produce any errors.

func WithViper added in v0.9.1

func WithViper(v unmarshaller, name, key string) Conf

WithViper produces an error any of the inputs are empty.

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 NewConfig

func NewConfig(conf ...Conf) (*Config, error)

NewConfig returns any errors that any of conf function return.

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() (recorder.DataRecorder, error)

NewInstance returns an instance of the elasticsearch recorder

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(options ...func(recorder.Constructor) error) (*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) Backoff added in v0.8.1

func (r *Recorder) Backoff() int

Backoff returns the backoff

func (*Recorder) Endpoint added in v0.8.1

func (r *Recorder) Endpoint() string

Endpoint returns the endpoint

func (*Recorder) IndexName added in v0.1.1

func (r *Recorder) IndexName() string

IndexName shows the indexName the recorder should record as

func (*Recorder) Name

func (r *Recorder) Name() string

Name shows the name identifier for this recorder

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) SetBackoff added in v0.8.1

func (r *Recorder) SetBackoff(backoff int)

SetBackoff sets the backoff of the recorder

func (*Recorder) SetEndpoint added in v0.8.1

func (r *Recorder) SetEndpoint(endpoint string)

SetEndpoint sets the endpoint of the recorder

func (*Recorder) SetIndexName added in v0.8.1

func (r *Recorder) SetIndexName(indexName string)

SetIndexName sets the type name of the recorder

func (*Recorder) SetLogger added in v0.8.1

func (r *Recorder) SetLogger(log internal.FieldLogger)

SetLogger sets the log of the recorder

func (*Recorder) SetName added in v0.8.1

func (r *Recorder) SetName(name string)

SetName sets the name of the recorder

func (*Recorder) SetTimeout added in v0.8.1

func (r *Recorder) SetTimeout(timeout time.Duration)

SetTimeout sets the timeout of the recorder

func (*Recorder) Timeout added in v0.1.1

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

Timeout returns the time-out

Jump to

Keyboard shortcuts

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