Skip to content

Commit

Permalink
breaking: rename RetryBackoff to RetryBackoffFn
Browse files Browse the repository at this point in the history
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
  • Loading branch information
twmb committed Aug 17, 2021
1 parent 8199f5b commit 12808d5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/kgo/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
}

Expand Down

0 comments on commit 12808d5

Please sign in to comment.