Skip to content
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

avoid setting default values to topic configuration #107

Conversation

blindspotbounty
Copy link
Collaborator

This is the fix for #106

Effectively, we should check that values are default and don't modify them. This way librdkafka would use default values from the main configuration.

@blindspotbounty blindspotbounty marked this pull request as ready for review July 31, 2023 10:26
Comment on lines +38 to +57
// librdkafka checks that values were modified from default (even if set to default)
// that may cause unexpected behaviour, so we should check that values are equal
var size = RDKafkaClient.stringSize
let configValue = UnsafeMutablePointer<CChar>.allocate(capacity: size)
defer { configValue.deallocate() }

if RD_KAFKA_CONF_OK == rd_kafka_topic_conf_get(configPointer, key, configValue, &size) {
let sizeNoNullTerm = size - 1
let wasVal = String(unsafeUninitializedCapacity: size) {
let buf = UnsafeRawBufferPointer(
UnsafeMutableRawBufferPointer(
start: configValue,
count: sizeNoNullTerm))
_ = $0.initialize(from: buf)
return sizeNoNullTerm
}
if wasVal == value {
return // Values are equal, avoid changing (don't mark config as modified)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felixschlegel Can you take a look at this. I am not super happy with going through C here to figure this out.

Do we only have to do this for the topic configuration? If so can we just do it on the Swift side and avoid setting anything that is the default value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants