Skip to content

Producer support for per-topic configs #449

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

Merged
merged 8 commits into from
May 8, 2024
Merged

Producer support for per-topic configs #449

merged 8 commits into from
May 8, 2024

Conversation

mensfeld
Copy link
Member

@mensfeld mensfeld commented May 6, 2024

This PR introduces the ability to use topic-specific custom settings as defined here: https://karafka.io/docs/Librdkafka-Configuration/ on a per-message dispatch basis.

This allows one producer to have different acks levels specific to topics and other custom settings.

In addition, it caches the rdkafka topic object so we do not have to create it with each request, saving on memory allocations. Since with_inner is locking, we do not have to worry about race conditions when adding configs to the cache.

We use the config hash value, so the same config created from different Ruby hash objects will reuse the same cache entry.

We allow multiple configs per the same topic because I've stumbled upon a case where the user had different importance messages delivered to the same topic and wanted to tune this. Makes sense to me.

close #436

@mensfeld mensfeld added enhancement producer Producer related issues labels May 6, 2024
@mensfeld mensfeld self-assigned this May 6, 2024
@mensfeld mensfeld requested review from thijsc and nijikon May 7, 2024 09:12
@mensfeld mensfeld marked this pull request as ready for review May 7, 2024 09:12
Copy link
Member

@nijikon nijikon left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@thijsc thijsc left a comment

Choose a reason for hiding this comment

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

Looking good!

@mensfeld mensfeld merged commit 2900f6a into main May 8, 2024
10 checks passed
@mensfeld mensfeld deleted the topic-producer branch May 8, 2024 08:53
mensfeld added a commit to karafka/karafka-rdkafka that referenced this pull request May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement producer Producer related issues
Development

Successfully merging this pull request may close these issues.

Support per-topic producer configuration alterations
4 participants