Skip to content

Commit

Permalink
Update transport to latest version with resilient retry (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anaethelion authored Dec 17, 2021
1 parent aacf60d commit 2c4492a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
9 changes: 4 additions & 5 deletions _benchmarks/benchmarks/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
"github.com/fatih/color"
"github.com/montanaflynn/stats"

"github.com/elastic/go-elasticsearch/v8"
"github.com/elastic/elastic-transport-go/v8/elastictransport"
"github.com/elastic/go-elasticsearch/v8"

"github.com/elastic/go-elasticsearch/v8/benchmarks"
"github.com/elastic/go-elasticsearch/v8/benchmarks/runner"
Expand Down Expand Up @@ -76,7 +76,7 @@ func main() {
log.Printf(boldUnderline("Running benchmarks for go-elasticsearch@%s; %s/go%s"), elasticsearch.Version, runner.RuntimeOS, runner.RuntimeVersion)

var missingConfigs []string
for k, _ := range benchmarks.Config {
for k := range benchmarks.Config {
v := os.Getenv(k)
if v == "" {
missingConfigs = append(missingConfigs, k)
Expand Down Expand Up @@ -120,9 +120,8 @@ func main() {
}

reportClientConfig := elasticsearch.Config{
Addresses: []string{benchmarks.Config["ELASTICSEARCH_REPORT_URL"]},
MaxRetries: 10,
EnableRetryOnTimeout: true,
Addresses: []string{benchmarks.Config["ELASTICSEARCH_REPORT_URL"]},
MaxRetries: 10,
}
if os.Getenv("DEBUG") != "" {
runnerClientConfig.Logger = &elastictransport.ColorLogger{Output: os.Stdout}
Expand Down
1 change: 1 addition & 0 deletions _benchmarks/benchmarks/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.14
replace github.com/elastic/go-elasticsearch/v8 => ../../

require (
github.com/elastic/elastic-transport-go/v8 v8.0.0-20211216131617-bbee439d559c
github.com/elastic/go-elasticsearch/v8 v8.0.0-20200408073057-6f36a473b19f
github.com/fatih/color v1.7.0
github.com/mattn/go-colorable v0.1.6 // indirect
Expand Down
18 changes: 9 additions & 9 deletions elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ type Config struct {
// The option is only valid when the transport is not specified, or when it's http.Transport.
CACert []byte

RetryOnStatus []int // List of status codes for retry. Default: 502, 503, 504.
DisableRetry bool // Default: false.
EnableRetryOnTimeout bool // Default: false.
MaxRetries int // Default: 3.
RetryOnStatus []int // List of status codes for retry. Default: 502, 503, 504.
DisableRetry bool // Default: false.
MaxRetries int // Default: 3.
RetryOnError func(*http.Request, error) bool // Optional function allowing to indicate which error should be retried. Default: nil.

CompressRequestBody bool // Default: false.

Expand Down Expand Up @@ -188,11 +188,11 @@ func NewClient(cfg Config) (*Client, error) {
Header: cfg.Header,
CACert: cfg.CACert,

RetryOnStatus: cfg.RetryOnStatus,
DisableRetry: cfg.DisableRetry,
EnableRetryOnTimeout: cfg.EnableRetryOnTimeout,
MaxRetries: cfg.MaxRetries,
RetryBackoff: cfg.RetryBackoff,
RetryOnStatus: cfg.RetryOnStatus,
DisableRetry: cfg.DisableRetry,
RetryOnError: cfg.RetryOnError,
MaxRetries: cfg.MaxRetries,
RetryBackoff: cfg.RetryBackoff,

CompressRequestBody: cfg.CompressRequestBody,

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/elastic/go-elasticsearch/v8

go 1.13

require github.com/elastic/elastic-transport-go/v8 v8.0.0-20211202110751-50105067ef27
require github.com/elastic/elastic-transport-go/v8 v8.0.0-20211216131617-bbee439d559c
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/elastic/elastic-transport-go/v8 v8.0.0-20211202110751-50105067ef27 h1:O58SwZ7pdt7Lzy8JqpJubJlgDbr9jVV7ro4HFPvaZDw=
github.com/elastic/elastic-transport-go/v8 v8.0.0-20211202110751-50105067ef27/go.mod h1:87Tcz8IVNe6rVSLdBux1o/PEItLtyabHU3naC7IoqKI=
github.com/elastic/elastic-transport-go/v8 v8.0.0-20211216131617-bbee439d559c h1:onA2RpIyeCPvYAj1LFYiiMTrSpqVINWMfYFRS7lofJs=
github.com/elastic/elastic-transport-go/v8 v8.0.0-20211216131617-bbee439d559c/go.mod h1:87Tcz8IVNe6rVSLdBux1o/PEItLtyabHU3naC7IoqKI=

0 comments on commit 2c4492a

Please sign in to comment.