Commit Graph

4 Commits

Author SHA1 Message Date
Julien 68524af701
Enable goheader rule and add missing license headers ()
This commit adds the `goheader` rule to `golangci-lint` to enforce that
all our Go source code includes appropriate licence headers, fixing up
files that currently fail that check.

---------

Co-authored-by: Will Jones <will@sacharissa.co.uk>
2024-09-09 12:05:45 +00:00
Abhinav Gupta cd00dbb4bb
sdk/common/retry: Fix extraneous backoff
The prior commit discovered that our retry logic backs off
by a longer delay than it needs to.
It doesn't respect the initial "delay" configuration,
and instead begins with "delay * backoff".

This change fixes the issue and updates the test expectations.
2023-03-24 16:39:02 -07:00
Abhinav Gupta 28cf555d01
sdk/common/retry: Allow injecting time.After, add tests
This extracts the core logic in the retry package into a Retryer struct.
The Retryer struct supports an optional "After" field,
which allows injecting a custom time.After implementation.

With this, we're able to write tests for this package
without actually sleeping (and slowing down the test suite).

Note that the tests exposed two surprising behaviors:

- If the context times out or expires, we correctly return `false`,
  but we return a nil error instead of `ctx.Err()`.
  I've chosen to not change this at this time
  because we don't know what that might break downstream.
- The initial delay is never used. We start with delay*backoff.
2023-03-24 16:32:22 -07:00
evanboyle 33e23bdf0c move pkg/util/retry -> sdk/go/common/util/retry 2020-03-18 15:47:01 -07:00