Skip to content

Commit b909358

Browse files
authored
Client: Implement product check on first call (#289)
* Client: Implement product check on first call * Examples: Update dependency retrieval * BulkIndexer: Update test to reflect product check changes * Client: Use sync.Once to restrict to one product check per client instance
1 parent 9747f0e commit b909358

File tree

25 files changed

+537
-62
lines changed

25 files changed

+537
-62
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ test-examples: ## Execute the _examples
101101
printf "\033[2m────────────────────────────────────────────────────────────────────────────────\n"; \
102102
printf "\033[1mUpdating dependencies for $$d\033[0m\n"; \
103103
printf "\033[2m────────────────────────────────────────────────────────────────────────────────\033[0m\n"; \
104-
(cd $$d && go mod download) || \
104+
(cd $$d && go mod download && make setup) || \
105105
( \
106106
printf "\033[31m────────────────────────────────────────────────────────────────────────────────\033[0m\n"; \
107107
printf "\033[31;1m⨯ ERROR\033[0m\n"; \
@@ -152,7 +152,7 @@ lint: ## Run lint on the package
152152
set -e ; \
153153
trap "test -d ../../../.git && git checkout --quiet go.mod" INT TERM EXIT; \
154154
echo "cd internal/build/ && go vet ./..."; \
155-
cd "internal/build/" && go mod download && go vet ./...; \
155+
cd "internal/build/" && go mod tidy && go mod download && go vet ./...; \
156156
}
157157

158158

_examples/bulk/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ test-benchmarks: clean setup
1313

1414
setup:
1515
@go get -u github.com/mailru/easyjson/...
16-
cd benchmarks && go generate ./model
16+
@go mod download github.com/dustin/go-humanize
17+
@go mod download github.com/cenkalti/backoff/v4
18+
cd benchmarks && go mod download && go mod download github.com/mailru/easyjson && go generate ./model
1719

1820
clean:
1921
@rm -f benchmarks/model/*_easyjson.go

_examples/bulk/benchmarks/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ replace github.com/elastic/go-elasticsearch/v7 => ../../..
66

77
require (
88
github.com/dustin/go-humanize v1.0.0
9-
github.com/elastic/go-elasticsearch/v7 7.x
9+
github.com/elastic/go-elasticsearch/v7 v7.5.1-0.20210608143310-9747f0e42f35
1010
github.com/mailru/easyjson v0.7.1
1111
github.com/montanaflynn/stats v0.6.3
1212
github.com/valyala/fasthttp v1.9.0

_examples/bulk/go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ replace github.com/elastic/go-elasticsearch/v7 => ../..
77
require (
88
github.com/cenkalti/backoff/v4 v4.0.0
99
github.com/dustin/go-humanize v1.0.0
10-
github.com/elastic/go-elasticsearch/v7 7.x
10+
github.com/elastic/go-elasticsearch/v7 v7.5.1-0.20210608143310-9747f0e42f35
11+
github.com/mailru/easyjson v0.7.7 // indirect
1112
)

_examples/cloudfunction/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ GO_TEST_CMD = $(if $(shell which richgo),richgo test,go test)
33
test: ## Run tests
44
$(GO_TEST_CMD) -v ./...
55

6-
.PHONY: test
6+
setup:
7+
8+
.PHONY: test setup

_examples/cloudfunction/function_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ type MockTransport struct{}
3535

3636
// RoundTrip returns a mock response.
3737
func (t *MockTransport) RoundTrip(req *http.Request) (*http.Response, error) {
38-
return &http.Response{Body: ioutil.NopCloser(strings.NewReader(`{"status":"mocked"}`))}, nil
38+
return &http.Response{
39+
Body: ioutil.NopCloser(strings.NewReader(`{"status":"mocked"}`)),
40+
Header: http.Header{"X-Elastic-Product": []string{"Elasticsearch"}},
41+
}, nil
3942
}
4043

4144
func TestHealth(t *testing.T) {

_examples/encoding/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ bench: clean setup # Run benchmarks
1010

1111
setup: ## Install & Setup
1212
@go get -u github.com/mailru/easyjson/...
13+
@go mod tidy
14+
@go mod download
1315
go generate ./model
1416

1517
clean: ## Remove artifacts

_examples/encoding/go.mod

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@ replace github.com/elastic/go-elasticsearch/v7 => ../..
66

77
require (
88
github.com/elastic/go-elasticsearch/v7 v7.0.0-20190407092644-3fb2a278216b
9-
109
github.com/fatih/color v1.7.0
11-
12-
github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983
10+
github.com/mailru/easyjson v0.7.7
1311
github.com/mattn/go-colorable v0.1.1 // indirect
1412
github.com/mattn/go-isatty v0.0.7 // indirect
15-
1613
github.com/tidwall/gjson v1.2.1
1714
github.com/tidwall/match v1.0.1 // indirect
1815
github.com/tidwall/pretty v0.0.0-20180105212114-65a9db5fad51 // indirect

_examples/extension/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ GO_TEST_CMD = $(if $(shell which richgo),richgo test,go test)
33
test: ## Run tests
44
go run main.go
55

6-
.PHONY: test
6+
setup:
7+
8+
.PHONY: test setup

_examples/fasthttp/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ test: ## Run tests
66
bench: ## Run benchmarks
77
$(GO_TEST_CMD) -run=none -bench=. -benchmem -benchtime=10s -v fasthttp_benchmark_test.go
88

9-
.PHONY: test bench
9+
setup:
10+
@go mod tidy
11+
@go mod download
12+
13+
.PHONY: test bench setup

0 commit comments

Comments
 (0)