From 8199f5b90673976ad0a8181feb2d803d8e920619 Mon Sep 17 00:00:00 2001 From: Travis Bischel Date: Tue, 17 Aug 2021 15:02:17 -0600 Subject: [PATCH] breaking: split RetryTimeout function 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. --- pkg/kgo/config.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pkg/kgo/config.go b/pkg/kgo/config.go index 375304cf..0c364517 100644 --- a/pkg/kgo/config.go +++ b/pkg/kgo/config.go @@ -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. @@ -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 }} }