Skip to content
This repository was archived by the owner on Oct 7, 2022. It is now read-only.

Commit 800877e

Browse files
author
Gabriel Mendes
committed
feat(elasticsearch): adds option to disable sniffing
1 parent fa742ef commit 800877e

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb
5353
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
5454
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
5555
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
56+
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
5657
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
5758
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w=
5859
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
@@ -173,6 +174,7 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJV
173174
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
174175
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ=
175176
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
177+
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
176178
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
177179
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
178180
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=

src/elasticsearch/config.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type Config struct {
2727
BulkTimeout time.Duration
2828
Backoff time.Duration
2929
TimeSuffix TimeIndexSuffix
30+
DisableSniffing bool
3031
}
3132

3233
func NewConfig() Config {
@@ -68,6 +69,15 @@ func NewConfig() Config {
6869
scheme = c
6970
}
7071
}
72+
73+
disableSniff := false
74+
if c := os.Getenv("ELASTICSEARCH_DISABLE_SNIFFING"); c != "" {
75+
res, err := strconv.ParseBool(c)
76+
if err == nil {
77+
disableSniff = res
78+
}
79+
}
80+
7181
return Config{
7282
Host: os.Getenv("ELASTICSEARCH_HOST"),
7383
User: os.Getenv("ELASTICSEARCH_USER"),
@@ -81,5 +91,6 @@ func NewConfig() Config {
8191
BulkTimeout: timeout,
8292
Backoff: backoff,
8393
TimeSuffix: timeSuffix,
94+
DisableSniffing: disableSniff,
8495
}
8596
}

src/elasticsearch/elasticsearch.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ func (d recordDatabase) GetClient() *elastic.Client {
4848
if d.config.Scheme == "https" { // http is default
4949
opts = append(opts, elastic.SetScheme(d.config.Scheme))
5050
}
51+
if d.config.DisableSniffing { // sniffing is enabled by default
52+
opts = append(opts, elastic.SetSniff(d.config.DisableSniffing))
53+
}
5154
client, err := elastic.NewClient(opts...)
5255
if err != nil {
5356
level.Error(d.logger).Log("err", err, "message", "could not init elasticsearch client")

0 commit comments

Comments
 (0)