Skip to content

Commit

Permalink
breaking: split RetryTimeout function
Browse files Browse the repository at this point in the history
For #62.

Using RetryTimeout is awkward, and the usual use case is to just have a
static timeout. This splits the current function based approach into
RetryTimeoutFn, and changes RetryTimeout into a static time.Duration
based option.
  • Loading branch information
twmb committed Aug 17, 2021
1 parent 7c2bfe3 commit 8199f5b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pkg/kgo/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,22 @@ func RequestRetries(n int) Opt {
// This timeout applies to any request issued through a client's Request
// function. It does not apply to fetches nor produces.
//
// A value of zero indicates no request timeout.
//
// The timeout is evaluated after a request is issued. If a retry backoff
// places the next request past the retry timeout deadline, the request will
// still be tried once more once the backoff expires.
func RetryTimeout(t time.Duration) Opt {
return RetryTimeoutFn(func(int16) time.Duration { return t })
}

// RetryTimeoutFn sets the per-request upper limit on how long we allow
// requests to retry, overriding the default of 5m for EndTxn requests, 1m for
// all others.
//
// This timeout applies to any request issued through a client's Request
// function. It does not apply to fetches nor produces.
//
// The function is called with the request key that is being retried. While it
// is not expected that the request key will be used, including it gives users
// the opportinuty to have different retry timeouts for different keys.
Expand All @@ -606,7 +622,7 @@ func RequestRetries(n int) Opt {
// The timeout is evaluated after a request is issued. If a retry backoff
// places the next request past the retry timeout deadline, the request will
// still be tried once more once the backoff expires.
func RetryTimeout(t func(int16) time.Duration) Opt {
func RetryTimeoutFn(t func(int16) time.Duration) Opt {
return clientOpt{func(cfg *cfg) { cfg.retryTimeout = t }}
}

Expand Down

0 comments on commit 8199f5b

Please sign in to comment.