Skip to content

Commit b5bd85f

Browse files
authored
add raising flag on wait in handler (#346)
1 parent 6617f6d commit b5bd85f

File tree

3 files changed

+96
-94
lines changed

3 files changed

+96
-94
lines changed

CHANGELOG.md

Lines changed: 92 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,141 @@
11
# Rdkafka Changelog
22

33
## 0.14.0 (Unreleased)
4+
- [Enhancement] Add `raise_response_error` flag to the `Rdkafka::AbstractHandle`.
45
- [Enhancement] Allow for setting `statistics_callback` as nil to reset predefined settings configured by a different gem (mensfeld)
5-
* [Enhancement] Get consumer position (thijsc & mensfeld)
6-
* [Enhancement] Provide `#purge` to remove any outstanding requests from the producer (mensfeld)
7-
* [Enhancement] Update `librdkafka` to `2.2.0` (mensfeld)
8-
* [Enhancement] Introduce producer partitions count metadata cache (mensfeld)
9-
* [Enhancement] Increase metadata timeout request from `250 ms` to `2000 ms` default to allow for remote cluster operations via `rdkafka-ruby` (mensfeld)
10-
* [Enhancement] Introduce `#name` for producers and consumers (mensfeld)
11-
* [Enhancement] Include backtrace in non-raised binded errors (mensfeld)
12-
* [Fix] Reference to Opaque is not released when Admin, Consumer or Producer is closed (mensfeld)
13-
* [Fix] Trigger `#poll` on native kafka creation to handle oauthbearer cb (mensfeld)
14-
* [Fix] `#flush` does not handle the timeouts errors by making it return `true` if all flushed or `false` if failed. We do **not** raise an exception here to keep it backwards compatible (mensfeld)
15-
* [Change] Remove support for Ruby 2.6 due to it being EOL and WeakMap incompatibilities (mensfeld)
16-
* [Change] Update Kafka Docker with Confluent KRaft (mensfeld)
17-
* [Change] Update librdkafka repo reference from edenhill to confluentinc (mensfeld)
6+
- [Enhancement] Get consumer position (thijsc & mensfeld)
7+
- [Enhancement] Provide `#purge` to remove any outstanding requests from the producer (mensfeld)
8+
- [Enhancement] Update `librdkafka` to `2.2.0` (mensfeld)
9+
- [Enhancement] Introduce producer partitions count metadata cache (mensfeld)
10+
- [Enhancement] Increase metadata timeout request from `250 ms` to `2000 ms` default to allow for remote cluster operations via `rdkafka-ruby` (mensfeld)
11+
- [Enhancement] Introduce `#name` for producers and consumers (mensfeld)
12+
- [Enhancement] Include backtrace in non-raised binded errors (mensfeld)
13+
- [Fix] Reference to Opaque is not released when Admin, Consumer or Producer is closed (mensfeld)
14+
- [Fix] Trigger `#poll` on native kafka creation to handle oauthbearer cb (mensfeld)
15+
- [Fix] `#flush` does not handle the timeouts errors by making it return `true` if all flushed or `false` if failed. We do **not** raise an exception here to keep it backwards compatible (mensfeld)
16+
- [Change] Remove support for Ruby 2.6 due to it being EOL and WeakMap incompatibilities (mensfeld)
17+
- [Change] Update Kafka Docker with Confluent KRaft (mensfeld)
18+
- [Change] Update librdkafka repo reference from edenhill to confluentinc (mensfeld)
1819

1920
## 0.13.0 (2023-07-24)
20-
* Support cooperative sticky partition assignment in the rebalance callback (methodmissing)
21-
* Support both string and symbol header keys (ColinDKelley)
22-
* Handle tombstone messages properly (kgalieva)
23-
* Add topic name to delivery report (maeve)
24-
* Allow string partitioner config (mollyegibson)
25-
* Fix documented type for DeliveryReport#error (jimmydo)
26-
* Bump librdkafka to 2.0.2 (lmaia)
27-
* Use finalizers to cleanly exit producer and admin (thijsc)
28-
* Lock access to the native kafka client (thijsc)
29-
* Fix potential race condition in multi-threaded producer (mensfeld)
30-
* Fix leaking FFI resources in specs (mensfeld)
31-
* Improve specs stability (mensfeld)
32-
* Make metadata request timeout configurable (mensfeld)
33-
* call_on_partitions_assigned and call_on_partitions_revoked only get a tpl passed in (thijsc)
21+
- Support cooperative sticky partition assignment in the rebalance callback (methodmissing)
22+
- Support both string and symbol header keys (ColinDKelley)
23+
- Handle tombstone messages properly (kgalieva)
24+
- Add topic name to delivery report (maeve)
25+
- Allow string partitioner config (mollyegibson)
26+
- Fix documented type for DeliveryReport#error (jimmydo)
27+
- Bump librdkafka to 2.0.2 (lmaia)
28+
- Use finalizers to cleanly exit producer and admin (thijsc)
29+
- Lock access to the native kafka client (thijsc)
30+
- Fix potential race condition in multi-threaded producer (mensfeld)
31+
- Fix leaking FFI resources in specs (mensfeld)
32+
- Improve specs stability (mensfeld)
33+
- Make metadata request timeout configurable (mensfeld)
34+
- call_on_partitions_assigned and call_on_partitions_revoked only get a tpl passed in (thijsc)
3435

3536
## 0.12.0 (2022-06-17)
36-
* Bumps librdkafka to 1.9.0
37-
* Fix crash on empty partition key (mensfeld)
38-
* Pass the delivery handle to the callback (gvisokinskas)
37+
- Bumps librdkafka to 1.9.0
38+
- Fix crash on empty partition key (mensfeld)
39+
- Pass the delivery handle to the callback (gvisokinskas)
3940

4041
## 0.11.0 (2021-11-17)
41-
* Upgrade librdkafka to 1.8.2
42-
* Bump supported minimum Ruby version to 2.6
43-
* Better homebrew path detection
42+
- Upgrade librdkafka to 1.8.2
43+
- Bump supported minimum Ruby version to 2.6
44+
- Better homebrew path detection
4445

4546
## 0.10.0 (2021-09-07)
46-
* Upgrade librdkafka to 1.5.0
47-
* Add error callback config
47+
- Upgrade librdkafka to 1.5.0
48+
- Add error callback config
4849

4950
## 0.9.0 (2021-06-23)
50-
* Fixes for Ruby 3.0
51-
* Allow any callable object for callbacks (gremerritt)
52-
* Reduce memory allocations in Rdkafka::Producer#produce (jturkel)
53-
* Use queue as log callback to avoid unsafe calls from trap context (breunigs)
54-
* Allow passing in topic configuration on create_topic (dezka)
55-
* Add each_batch method to consumer (mgrosso)
51+
- Fixes for Ruby 3.0
52+
- Allow any callable object for callbacks (gremerritt)
53+
- Reduce memory allocations in Rdkafka::Producer#produce (jturkel)
54+
- Use queue as log callback to avoid unsafe calls from trap context (breunigs)
55+
- Allow passing in topic configuration on create_topic (dezka)
56+
- Add each_batch method to consumer (mgrosso)
5657

5758
## 0.8.1 (2020-12-07)
58-
* Fix topic_flag behaviour and add tests for Metadata (geoff2k)
59-
* Add topic admin interface (geoff2k)
60-
* Raise an exception if @native_kafka is nil (geoff2k)
61-
* Option to use zstd compression (jasonmartens)
59+
- Fix topic_flag behaviour and add tests for Metadata (geoff2k)
60+
- Add topic admin interface (geoff2k)
61+
- Raise an exception if @native_kafka is nil (geoff2k)
62+
- Option to use zstd compression (jasonmartens)
6263

6364
## 0.8.0 (2020-06-02)
64-
* Upgrade librdkafka to 1.4.0
65-
* Integrate librdkafka metadata API and add partition_key (by Adithya-copart)
66-
* Ruby 2.7 compatibility fix (by Geoff Thé)A
67-
* Add error to delivery report (by Alex Stanovsky)
68-
* Don't override CPPFLAGS and LDFLAGS if already set on Mac (by Hiroshi Hatake)
69-
* Allow use of Rake 13.x and up (by Tomasz Pajor)
65+
- Upgrade librdkafka to 1.4.0
66+
- Integrate librdkafka metadata API and add partition_key (by Adithya-copart)
67+
- Ruby 2.7 compatibility fix (by Geoff Thé)A
68+
- Add error to delivery report (by Alex Stanovsky)
69+
- Don't override CPPFLAGS and LDFLAGS if already set on Mac (by Hiroshi Hatake)
70+
- Allow use of Rake 13.x and up (by Tomasz Pajor)
7071

7172
## 0.7.0 (2019-09-21)
72-
* Bump librdkafka to 1.2.0 (by rob-as)
73-
* Allow customizing the wait time for delivery report availability (by mensfeld)
73+
- Bump librdkafka to 1.2.0 (by rob-as)
74+
- Allow customizing the wait time for delivery report availability (by mensfeld)
7475

7576
## 0.6.0 (2019-07-23)
76-
* Bump librdkafka to 1.1.0 (by Chris Gaffney)
77-
* Implement seek (by breunigs)
77+
- Bump librdkafka to 1.1.0 (by Chris Gaffney)
78+
- Implement seek (by breunigs)
7879

7980
## 0.5.0 (2019-04-11)
80-
* Bump librdkafka to 1.0.0 (by breunigs)
81-
* Add cluster and member information (by dmexe)
82-
* Support message headers for consumer & producer (by dmexe)
83-
* Add consumer rebalance listener (by dmexe)
84-
* Implement pause/resume partitions (by dmexe)
81+
- Bump librdkafka to 1.0.0 (by breunigs)
82+
- Add cluster and member information (by dmexe)
83+
- Support message headers for consumer & producer (by dmexe)
84+
- Add consumer rebalance listener (by dmexe)
85+
- Implement pause/resume partitions (by dmexe)
8586

8687
## 0.4.2 (2019-01-12)
87-
* Delivery callback for producer
88-
* Document list param of commit method
89-
* Use default Homebrew openssl location if present
90-
* Consumer lag handles empty topics
91-
* End iteration in consumer when it is closed
92-
* Add support for storing message offsets
93-
* Add missing runtime dependency to rake
88+
- Delivery callback for producer
89+
- Document list param of commit method
90+
- Use default Homebrew openssl location if present
91+
- Consumer lag handles empty topics
92+
- End iteration in consumer when it is closed
93+
- Add support for storing message offsets
94+
- Add missing runtime dependency to rake
9495

9596
## 0.4.1 (2018-10-19)
96-
* Bump librdkafka to 0.11.6
97+
- Bump librdkafka to 0.11.6
9798

9899
## 0.4.0 (2018-09-24)
99-
* Improvements in librdkafka archive download
100-
* Add global statistics callback
101-
* Use Time for timestamps, potentially breaking change if you
100+
- Improvements in librdkafka archive download
101+
- Add global statistics callback
102+
- Use Time for timestamps, potentially breaking change if you
102103
rely on the previous behavior where it returns an integer with
103104
the number of milliseconds.
104-
* Bump librdkafka to 0.11.5
105-
* Implement TopicPartitionList in Ruby so we don't have to keep
105+
- Bump librdkafka to 0.11.5
106+
- Implement TopicPartitionList in Ruby so we don't have to keep
106107
track of native objects.
107-
* Support committing a topic partition list
108-
* Add consumer assignment method
108+
- Support committing a topic partition list
109+
- Add consumer assignment method
109110

110111
## 0.3.5 (2018-01-17)
111-
* Fix crash when not waiting for delivery handles
112-
* Run specs on Ruby 2.5
112+
- Fix crash when not waiting for delivery handles
113+
- Run specs on Ruby 2.5
113114

114115
## 0.3.4 (2017-12-05)
115-
* Bump librdkafka to 0.11.3
116+
- Bump librdkafka to 0.11.3
116117

117118
## 0.3.3 (2017-10-27)
118-
* Fix bug that prevent display of `RdkafkaError` message
119+
- Fix bug that prevent display of `RdkafkaError` message
119120

120121
## 0.3.2 (2017-10-25)
121-
* `add_topic` now supports using a partition count
122-
* Add way to make errors clearer with an extra message
123-
* Show topics in subscribe error message
124-
* Show partition and topic in query watermark offsets error message
122+
- `add_topic` now supports using a partition count
123+
- Add way to make errors clearer with an extra message
124+
- Show topics in subscribe error message
125+
- Show partition and topic in query watermark offsets error message
125126

126127
## 0.3.1 (2017-10-23)
127-
* Bump librdkafka to 0.11.1
128-
* Officially support ranges in `add_topic` for topic partition list.
129-
* Add consumer lag calculator
128+
- Bump librdkafka to 0.11.1
129+
- Officially support ranges in `add_topic` for topic partition list.
130+
- Add consumer lag calculator
130131

131132
## 0.3.0 (2017-10-17)
132-
* Move both add topic methods to one `add_topic` in `TopicPartitionList`
133-
* Add committed offsets to consumer
134-
* Add query watermark offset to consumer
133+
- Move both add topic methods to one `add_topic` in `TopicPartitionList`
134+
- Add committed offsets to consumer
135+
- Add query watermark offset to consumer
135136

136137
## 0.2.0 (2017-10-13)
137-
* Some refactoring and add inline documentation
138+
- Some refactoring and add inline documentation
138139

139140
## 0.1.x (2017-09-10)
140-
* Initial working version including producing and consuming
141+
- Initial working version including producing and consuming

lib/rdkafka/abstract_handle.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ def pending?
4848
# If this is nil it does not time out.
4949
# @param wait_timeout [Numeric] Amount of time we should wait before we recheck if the
5050
# operation has completed
51+
# @param raise_response_error [Boolean] should we raise error when waiting finishes
5152
#
5253
# @return [Object] Operation-specific result
5354
#
5455
# @raise [RdkafkaError] When the operation failed
5556
# @raise [WaitTimeoutError] When the timeout has been reached and the handle is still pending
56-
def wait(max_wait_timeout: 60, wait_timeout: 0.1)
57+
def wait(max_wait_timeout: 60, wait_timeout: 0.1, raise_response_error: true)
5758
timeout = if max_wait_timeout
5859
monotonic_now + max_wait_timeout
5960
else
@@ -67,7 +68,7 @@ def wait(max_wait_timeout: 60, wait_timeout: 0.1)
6768
)
6869
end
6970
sleep wait_timeout
70-
elsif self[:response] != 0
71+
elsif self[:response] != 0 && raise_response_error
7172
raise_error
7273
else
7374
return create_result

lib/rdkafka/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
module Rdkafka
4-
VERSION = "0.13.0"
4+
VERSION = "0.14.0.rc1"
55
LIBRDKAFKA_VERSION = "2.2.0"
66
LIBRDKAFKA_SOURCE_SHA256 = "af9a820cbecbc64115629471df7c7cecd40403b6c34bfdbb9223152677a47226"
77
end

0 commit comments

Comments
 (0)