Skip to content

[proposal] Remove interfaces and functions from go-elasticsearch.Config #713

Open
@florianl

Description

@florianl

Status Quo

go-elasticsearch.Config defines how one can interact with Elasticsearch. At the moment this struct holds a mix of types, functions and interfaces.

Functions:

RetryOnError func(*http.Request, error) bool // Optional function allowing to indicate which error should be retried. Default: nil.

RetryBackoff func(attempt int) time.Duration // Optional backoff duration. Default: nil.

ConnectionPoolFunc func([]*elastictransport.Connection, elastictransport.Selector) elastictransport.ConnectionPool

Interfaces:

Logger elastictransport.Logger // The logger object.
Selector elastictransport.Selector // The selector object.

Problem

The functions and interfaces in go-elasticsearch.Config prevent users of elastic/go-elasticsearch to directly use go-elasticsearch.Config. The direct reuse of go-elasticsearch.Config is prevented, because it can not be configured, usually via YAML, and services are required to allow users to configure the connection to Elasticsearch. Common dependencies to handle configuration within the Elastic ecosystem are elastic/go-ucfg and elastic/elastic-agent-libs/config. As it is not possible to configure interfaces and/or functions with YAML, services that have to use go-elasticsearch.Config come up with their reimplemenation of go-elasticsearch.Config:

None of these reimplementations of go-elasticsearch.Config fully cover all parts of go-elasticsearch.Config , lead to duplicate code and might introduce subtile bugs. In addition, configuring the retry functionality is different from service to service and prevents the reuse of configurations.

Proposal

Remove interfaces and functions from go-elasticsearch.Config. One option to keep functionality is, is to introduce Getter/Setter.

The suggested proposal is a breaking change and not backwards compatible.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions