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

Provide context based producer variants #483

Merged
merged 12 commits into from
May 9, 2024
Merged

Provide context based producer variants #483

merged 12 commits into from
May 9, 2024

Conversation

mensfeld
Copy link
Member

@mensfeld mensfeld commented May 8, 2024

This PR introduces producer context variants that allow you to have different settings per topic with one producer. This allows for utilization of the same producer TCP connections while still being able to alter the dispatch requirements.

producer = WaterDrop::Producer.new do |config|
  config.kafka = {
    'bootstrap.servers': 'localhost:9092',
    'acks': '2'
  }
end

# You can define variants
low_importance = producer.with(topic_config: { acks: 1 })
hig_importance = producer.with(topic_config: { acks: 2 })

# and use them as regular producers:
low_importance.produce_async(topic: 'events', payload: event.to_json)

@mensfeld mensfeld requested a review from nijikon May 8, 2024 09:35
@mensfeld mensfeld self-assigned this May 8, 2024
@mensfeld mensfeld changed the title Context Provide context based producer variants May 8, 2024
@mensfeld mensfeld marked this pull request as ready for review May 8, 2024 09:54
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

@mensfeld mensfeld merged commit 0acec3a into master May 9, 2024
13 checks passed
@mensfeld mensfeld deleted the context branch May 9, 2024 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants