From 12808d507749f6c191e5be5b031f1a5c7b14b7c2 Mon Sep 17 00:00:00 2001 From: Travis Bischel Date: Tue, 17 Aug 2021 15:08:05 -0600 Subject: [PATCH] breaking: rename RetryBackoff to RetryBackoffFn This reads more accurately when specifying options. All options that take functions now somewhat imply they take a function, or they more obviously already take a function: func CommitCallback(fn func(*Client, *kmsg.OffsetCommitRequest, *kmsg.OffsetCommitResponse, error)) GroupOpt func OnAssigned(onAssigned func(context.Context, *Client, map[string][]int32)) GroupOpt func OnLost(onLost func(context.Context, *Client, map[string][]int32)) GroupOpt func OnRevoked(onRevoked func(context.Context, *Client, map[string][]int32)) GroupOpt func BasicLogger(dst io.Writer, level LogLevel, prefixFn func() string) Logger func Dialer(fn func(ctx context.Context, network, host string) (net.Conn, error)) Opt func RetryBackoffFn(backoff func(int) time.Duration) Opt func RetryTimeoutFn(t func(int16) time.Duration) Opt func BasicConsistentPartitioner(partition func(string) func(r *Record, n int) int) Partitioner func KafkaHasher(hashFn func([]byte) uint32) PartitionerHasher func SaramaHasher(hashFn func([]byte) uint32) PartitionerHasher func OnDataLoss(fn func(string, int32)) ProducerOpt --- pkg/kgo/config.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/kgo/config.go b/pkg/kgo/config.go index 0c364517..ea7f2c30 100644 --- a/pkg/kgo/config.go +++ b/pkg/kgo/config.go @@ -572,13 +572,13 @@ func MinVersions(versions *kversion.Versions) Opt { return clientOpt{func(cfg *cfg) { cfg.minVersions = versions }} } -// RetryBackoff sets the backoff strategy for how long to backoff for a given -// amount of retries, overriding the default exponential backoff that ranges -// from 100ms min to 1s max. +// RetryBackoffFn sets the backoff strategy for how long to backoff for a given +// amount of retries, overriding the default jittery exponential backoff that +// ranges from 100ms min to 1s max. // // This (roughly) corresponds to Kafka's retry.backoff.ms setting and // retry.backoff.max.ms (which is being introduced with KIP-500). -func RetryBackoff(backoff func(int) time.Duration) Opt { +func RetryBackoffFn(backoff func(int) time.Duration) Opt { return clientOpt{func(cfg *cfg) { cfg.retryBackoff = backoff }} }