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

Commit 9821220

Browse files
authored
Merge pull request #38 from inloco/feature/elasticsearch-disable-sniffing
feat(elasticsearch): adds option to disable sniffing
2 parents fa742ef + bb7cb81 commit 9821220

File tree

5 files changed

+29
-10
lines changed

5 files changed

+29
-10
lines changed

.circleci/config.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 2.1
22
defaults: &defaults
33
environment:
4-
DOCKER_REPO: inlocomedia/kafka-elasticsearch-injector-go
4+
DOCKER_REPO: quay.io/inloco/kafka-elasticsearch-injector
55
jobs:
66
test:
77
<<: *defaults
@@ -33,7 +33,7 @@ jobs:
3333
name: Login to Docker Hub
3434
command: |
3535
docker info
36-
docker login --username $DOCKER_USER --password $DOCKER_PASSWORD
36+
docker login --username $DOCKER_USER --password $DOCKER_PASSWORD quay.io
3737
- restore_cache:
3838
keys:
3939
- go-mod-v4-{{ checksum "go.sum" }}
@@ -106,7 +106,7 @@ jobs:
106106
docker load -i /tmp/workspace/image.tar
107107
- run:
108108
name: "docker login"
109-
command: docker login --username $DOCKER_USER --password $DOCKER_PASSWORD
109+
command: docker login --username $DOCKER_USER --password $DOCKER_PASSWORD quay.io
110110
- run:
111111
name: Push images
112112
command: |
@@ -128,13 +128,14 @@ workflows:
128128
test-and-deploy-image-for-commit:
129129
jobs:
130130
- test:
131-
filters:
132-
branches:
133-
ignore: /master/
131+
context: quay-push-credentials
132+
filters:
133+
branches:
134+
ignore: /master/
134135
- build-image:
135-
filters:
136-
branches:
137-
ignore: /master/
136+
filters:
137+
branches:
138+
ignore: /master/
138139
- deploy-image:
139140
context: media
140141
requires:
@@ -145,6 +146,7 @@ workflows:
145146
test-and-deploy-image-for-tag:
146147
jobs:
147148
- test:
149+
context: quay-push-credentials
148150
filters:
149151
tags:
150152
only: /.+/
@@ -165,4 +167,4 @@ workflows:
165167
tags:
166168
only: /.+/
167169
branches:
168-
ignore: /.*/
170+
ignore: /.*/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ To create new injectors for your topics, you should create a new kubernetes depl
2525
- `ELASTICSEARCH_PASSWORD` Elasticsearch password. **OPTIONAL**
2626
- `ELASTICSEARCH_SCHEME` scheme to be used when connecting to elasticsearch(http or https). Defaults to http. **OPTIONAL**
2727
- `ELASTICSEARCH_IGNORE_CERT` if set to "true", ignores certificates when connecting to a secure elasticsearch cluster. Defaults to false. **OPTIONAL**
28+
- `ELASTICSEARCH_DISABLE_SNIFFING` if set to "true", the client will not sniff Elasticsearch nodes during the node discovery process. Defaults to false. **OPTIONAL**
2829
- `KAFKA_CONSUMER_CONCURRENCY` Number of parallel goroutines working as a consumer. Default value is 1 **OPTIONAL**
2930
- `KAFKA_CONSUMER_BATCH_SIZE` Number of records to accumulate before sending them to elasticsearch(for each goroutine). Default value is 100 **OPTIONAL**
3031
- `ES_INDEX_COLUMN` Record field to append to index name. Ex: to create one ES index per campaign, use "campaign_id" here **OPTIONAL**

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)