Skip to content

Add support for fetch.wait.max.ms Kafka consumer config #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Sources/Kafka/Configuration/KafkaConsumerConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,20 @@ public struct KafkaConsumerConfiguration {
}
}

/// The maximum amount of time the server will block before answering the fetch request
/// there isn’t sufficient data to immediately satisfy the requirement given by fetch.min.bytes.
/// Default: `.milliseconds(500)`
public var maximumFetchWaitTime: Duration = .milliseconds(500) {
didSet {
if maximumFetchWaitTime != .zero {
precondition(
maximumFetchWaitTime.canBeRepresentedAsMilliseconds,
"Lowest granularity is milliseconds"
)
}
}
}

/// Topic metadata options.
public var topicMetadata: KafkaConfiguration.TopicMetadataOptions = .init()

Expand Down Expand Up @@ -260,6 +274,7 @@ extension KafkaConsumerConfiguration {
resultDict["receive.message.max.bytes"] = String(maximumReceiveMessageBytes)
resultDict["max.in.flight.requests.per.connection"] = String(maximumInFlightRequestsPerConnection)
resultDict["metadata.max.age.ms"] = String(maximumMetadataAge.inMilliseconds)
resultDict["fetch.wait.max.ms"] = String(maximumFetchWaitTime.inMilliseconds)
resultDict["topic.metadata.refresh.interval.ms"] = String(topicMetadata.refreshInterval.rawValue)
resultDict["topic.metadata.refresh.fast.interval.ms"] = String(topicMetadata.refreshFastInterval.inMilliseconds)
resultDict["topic.metadata.refresh.sparse"] = String(topicMetadata.isSparseRefreshingEnabled)
Expand Down