Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions etherclient/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,23 @@ func (ec *etherClient) withBackoff(
wrapper := ec.provider.Provide()
ethClient := wrapper.Client
tCtx, cancel := context.WithTimeout(ctx, backoffContextTimeout)
err := operation(tCtx, ethClient)
opErr := operation(tCtx, ethClient)
cancel()

// If metrics handler is set, call with the RPC URL and the client method that was used.
if ec.metricsHandler != nil {
rpcUrl := wrapper.url
u, err := url.Parse(rpcUrl)
if err == nil {
ec.metricsHandler(u.Host, method)
u, parseErr := url.Parse(rpcUrl)
if parseErr == nil {
ec.metricsHandler(u.Host, method, opErr)
}
}

if err != nil {
if opErr != nil {
// Move onto the next provider.
ec.provider.Next()
}
return handleRetryErr(ctx, method, err)
return handleRetryErr(ctx, method, opErr)
}, bo)
if err != nil {
logrus.WithError(err).WithField("method", method).Error("retry failed with error")
Expand Down
6 changes: 3 additions & 3 deletions etherclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type EtherClient interface {
Extras

SetRetryInterval(d time.Duration)
SetMetricsHandler(h func(rpcHost, clientMethod string))
SetMetricsHandler(h func(rpcHost, clientMethod string, err error))
}

type Extras interface {
Expand Down Expand Up @@ -85,7 +85,7 @@ type etherClient struct {
provider provider.Provider[*ethClientWrapper]
retryInterval time.Duration

metricsHandler func(rpcHost, clientMethod string)
metricsHandler func(rpcHost, clientMethod string, err error)
}

var _ EtherClient = &etherClient{}
Expand Down Expand Up @@ -121,7 +121,7 @@ func (ec *etherClient) SetRetryInterval(d time.Duration) {
ec.retryInterval = d
}

func (ec *etherClient) SetMetricsHandler(h func(rpcHost, clientMethod string)) {
func (ec *etherClient) SetMetricsHandler(h func(rpcHost, clientMethod string, err error)) {
ec.metricsHandler = h
}

Expand Down
2 changes: 1 addition & 1 deletion etherclient/mocks/mock_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading