Skip to content

Commit

Permalink
support producers tagging
Browse files Browse the repository at this point in the history
  • Loading branch information
mensfeld committed Jan 8, 2025
1 parent 03854df commit e1edbba
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# WaterDrop changelog

## 2.8.2 (Unreleased)
- [Feature] Allow for tagging of producer instances similar to how consumers can be tagged.

## 2.8.1 (2024-12-26)
- [Enhancement] Raise `WaterDrop::ProducerNotTransactionalError` when attempting to use transactions on a non-transactional producer.
- [Fix] Disallow closing a producer from within a transaction.
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
waterdrop (2.8.1)
waterdrop (2.8.2)
karafka-core (>= 2.4.3, < 3.0.0)
karafka-rdkafka (>= 0.17.5)
zeitwerk (~> 2.3)
Expand Down
1 change: 1 addition & 0 deletions lib/waterdrop/producer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Producer
include Buffer
include Transactions
include ::Karafka::Core::Helpers::Time
include ::Karafka::Core::Taggable

# Local storage for given thread waterdrop client references for variants
::Fiber.send(:attr_accessor, :waterdrop_clients)
Expand Down
2 changes: 1 addition & 1 deletion lib/waterdrop/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# WaterDrop library
module WaterDrop
# Current WaterDrop version
VERSION = '2.8.1'
VERSION = '2.8.2'
end
13 changes: 13 additions & 0 deletions spec/lib/waterdrop/producer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,19 @@ def on_oauthbearer_token_refresh(_); end
end
end

describe '#tags' do
let(:producer1) { build(:producer) }
let(:producer2) { build(:producer) }

before do
producer1.tags.add(:type, 'transactional')
producer2.tags.add(:type, 'regular')
end

it { expect(producer1.tags.to_a).to eq(%w[transactional]) }
it { expect(producer2.tags.to_a).to eq(%w[regular]) }
end

describe 'statistics callback hook' do
let(:message) { build(:valid_message) }

Expand Down

0 comments on commit e1edbba

Please sign in to comment.