Skip to content

Commit 8992265

Browse files
committed
opt: To prevent redundant error reporting, just return the most recent error instance. For systematic tracking of retry failures, utilize the logger plugin's OnError handler to implement centralized error collection.
1 parent 677efee commit 8992265

File tree

3 files changed

+3
-14
lines changed

3 files changed

+3
-14
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ require (
66
github.com/DataDog/datadog-go v3.7.1+incompatible // indirect
77
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
88
github.com/cactus/go-statsd-client/statsd v0.0.0-20200423205355-cb0885a1018c // indirect
9-
github.com/gojek/valkyrie v0.0.0-20180215180059-6aee720afcdf
109
github.com/pkg/errors v0.9.1
1110
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
1211
github.com/smartystreets/goconvey v1.6.4 // indirect

go.sum

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 h1:rFw4nCn9iMW+Vaj
44
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
55
github.com/cactus/go-statsd-client/statsd v0.0.0-20200423205355-cb0885a1018c h1:HIGF0r/56+7fuIZw2V4isE22MK6xpxWx7BbV8dJ290w=
66
github.com/cactus/go-statsd-client/statsd v0.0.0-20200423205355-cb0885a1018c/go.mod h1:l/bIBLeOl9eX+wxJAzxS4TveKRtAqlyDpHjhkfO0MEI=
7-
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
87
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
98
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
109
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
11-
github.com/gojek/valkyrie v0.0.0-20180215180059-6aee720afcdf h1:5xRGbUdOmZKoDXkGx5evVLehuCMpuO1hl701bEQqXOM=
12-
github.com/gojek/valkyrie v0.0.0-20180215180059-6aee720afcdf/go.mod h1:QzhUKaYKJmcbTnCYCAVQrroCOY7vOOI8cSQ4NbuhYf0=
1310
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
1411
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
1512
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=

httpclient/client.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
"net/http"
99
"time"
1010

11-
"github.com/gojek/heimdall/v7"
12-
"github.com/gojek/valkyrie"
1311
"github.com/pkg/errors"
12+
13+
heimdall "github.com/gojek/heimdall/v7"
1414
)
1515

1616
// Client is the http client implementation
@@ -136,7 +136,6 @@ func (c *Client) Do(request *http.Request) (*http.Response, error) {
136136
request.Body = ioutil.NopCloser(bodyReader) // prevents closing the body between retries
137137
}
138138

139-
multiErr := &valkyrie.MultiError{}
140139
var err error
141140
var shouldRetry bool
142141
var response *http.Response
@@ -158,7 +157,6 @@ func (c *Client) Do(request *http.Request) (*http.Response, error) {
158157
shouldRetry, err = c.checkRetry(request.Context(), response, err)
159158

160159
if err != nil {
161-
multiErr.Push(err.Error())
162160
c.reportError(request, err)
163161
} else {
164162
c.reportRequestEnd(request, response)
@@ -182,12 +180,7 @@ func (c *Client) Do(request *http.Request) (*http.Response, error) {
182180
}
183181
}
184182

185-
if !shouldRetry && err == nil {
186-
// Clear errors if any iteration succeeds
187-
multiErr = &valkyrie.MultiError{}
188-
}
189-
190-
return response, multiErr.HasError()
183+
return response, err
191184
}
192185

193186
func (c *Client) checkRetry(ctx context.Context, resp *http.Response, err error) (bool, error) {

0 commit comments

Comments
 (0)