Documentation ¶
Overview ¶
Package elasticsearch contains logic to record data to an elasticsearch index. The data is already sanitised by the data provider.
Index ¶
- type Conf
- type Config
- type Recorder
- func (r *Recorder) Backoff() int
- func (r *Recorder) Endpoint() string
- func (r *Recorder) IndexName() string
- func (r *Recorder) Name() string
- func (r *Recorder) Ping() error
- func (r *Recorder) Record(ctx context.Context, job recorder.Job) error
- func (r *Recorder) SetBackoff(backoff int)
- func (r *Recorder) SetEndpoint(endpoint string)
- func (r *Recorder) SetIndexName(indexName string)
- func (r *Recorder) SetLogger(log tools.FieldLogger)
- func (r *Recorder) SetName(name string)
- func (r *Recorder) SetTimeout(timeout time.Duration)
- func (r *Recorder) Timeout() time.Duration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conf ¶ added in v0.9.1
Conf func is used for initializing a Config object.
func WithLogger ¶ added in v0.9.1
func WithLogger(log tools.FieldLogger) Conf
WithLogger produces an error if the log is nil.
type Config ¶
type Config struct { ESEndpoint string `mapstructure:"endpoint"` ESTimeout string `mapstructure:"timeout"` ESBackoff int `mapstructure:"backoff"` ESIndexName string `mapstructure:"index_name"` ESName string ConfTimeout time.Duration // contains filtered or unexported fields }
Config holds the necessary configuration for setting up an elasticsearch reader endpoint from a configuration file.
func NewConfig ¶
NewConfig is used for returning the values from config file. It returns any errors that any of conf function return.
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 | InvalidEndpointError | | backoff < 5 | LowBackoffValueError | | Empty name | ErrEmptyName | | Invalid IndexName | InvalidIndexNameError | | Empty IndexName | ErrEmptyIndexName | +-------------------+-----------------------+
func (*Recorder) IndexName ¶ added in v0.1.1
IndexName shows the indexName the recorder should record as
func (*Recorder) Ping ¶ added in v0.7.0
Ping should ping the endpoint and report if was successful. It returns and error on the following occasions:
+----------------------+---------------------------+ | Condition | Error | +----------------------+---------------------------+ | Unavailable endpoint | EndpointNotAvailableError | | Ping errors | Timeout/Ping failed | | Index creation | elasticsearch's errors | +----------------------+---------------------------+
func (*Recorder) Record ¶ added in v0.6.0
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
SetBackoff sets the backoff of the recorder
func (*Recorder) SetEndpoint ¶ added in v0.8.1
SetEndpoint sets the endpoint of the recorder
func (*Recorder) SetIndexName ¶ added in v0.8.1
SetIndexName sets the type name of the recorder
func (*Recorder) SetLogger ¶ added in v0.8.1
func (r *Recorder) SetLogger(log tools.FieldLogger)
SetLogger sets the log of the recorder
func (*Recorder) SetTimeout ¶ added in v0.8.1
SetTimeout sets the timeout of the recorder