Skip to content

Commit 7e3715a

Browse files
chore: create new backoff on every reporting request (#5993)
# Description With the shared backoff, the retries could be waiting for longer time than required. With this PR, we are creating new backoff for every request ## Security - [ ] The code changed/added as part of this pull request won't create any security issues with how the software is being used.
1 parent 01483d5 commit 7e3715a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

enterprise/reporting/client/client.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@ type Client struct {
6565
reportingServiceURL string
6666

6767
httpClient *http.Client
68-
backoff backoff.BackOff
6968
stats stats.Stats
7069
log logger.Logger
7170

7271
moduleName string
7372
instanceID string
73+
74+
conf *config.Config
7475
}
7576

7677
func backOffFromConfig(conf *config.Config) backoff.BackOff {
@@ -99,12 +100,12 @@ func New(path Route, conf *config.Config, log logger.Logger, stats stats.Stats)
99100
Transport: &http.Transport{},
100101
},
101102
reportingServiceURL: reportingServiceURL,
102-
backoff: backOffFromConfig(conf),
103103
route: path,
104104
instanceID: conf.GetString("INSTANCE_ID", "1"),
105105
moduleName: conf.GetString("clientName", ""),
106106
stats: stats,
107107
log: log,
108+
conf: conf,
108109
}
109110
}
110111

@@ -157,7 +158,7 @@ func (c *Client) Send(ctx context.Context, payload any) error {
157158
return err
158159
}
159160

160-
b := backoff.WithContext(c.backoff, ctx)
161+
b := backoff.WithContext(backOffFromConfig(c.conf), ctx)
161162
err = backoff.RetryNotify(o, b, func(err error, t time.Duration) {
162163
c.log.Warnn(`Error reporting to service, retrying`, obskit.Error(err))
163164
})

0 commit comments

Comments
 (0)