karafka-rdkafka 0.31.0-aarch64-linux-gnu → 0.32.1-aarch64-linux-gnu

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +100 -35
  3. data/README.md +14 -6
  4. data/ext/librdkafka.so +0 -0
  5. data/karafka-rdkafka.gemspec +4 -3
  6. data/lib/rdkafka/abstract_handle.rb +26 -11
  7. data/lib/rdkafka/admin/acl_binding_result.rb +4 -16
  8. data/lib/rdkafka/admin/alter_consumer_group_offsets_report.rb +2 -2
  9. data/lib/rdkafka/admin/config_binding_result.rb +8 -0
  10. data/lib/rdkafka/admin/create_acl_report.rb +1 -3
  11. data/lib/rdkafka/admin/create_topic_report.rb +2 -6
  12. data/lib/rdkafka/admin/delete_consumer_group_offsets_report.rb +2 -2
  13. data/lib/rdkafka/admin/delete_groups_report.rb +2 -6
  14. data/lib/rdkafka/admin/delete_topic_report.rb +2 -6
  15. data/lib/rdkafka/admin/describe_cluster_report.rb +3 -0
  16. data/lib/rdkafka/admin/list_consumer_group_offsets_handle.rb +31 -0
  17. data/lib/rdkafka/admin/list_consumer_group_offsets_report.rb +52 -0
  18. data/lib/rdkafka/admin.rb +180 -10
  19. data/lib/rdkafka/bindings/admin/configs.rb +12 -1
  20. data/lib/rdkafka/bindings/admin.rb +14 -0
  21. data/lib/rdkafka/bindings/callbacks.rb +16 -9
  22. data/lib/rdkafka/bindings/configuration.rb +3 -3
  23. data/lib/rdkafka/bindings/consumer.rb +44 -2
  24. data/lib/rdkafka/bindings/errors.rb +1 -1
  25. data/lib/rdkafka/bindings/handle.rb +1 -1
  26. data/lib/rdkafka/bindings.rb +3 -0
  27. data/lib/rdkafka/callbacks/list_consumer_group_offsets_handler.rb +62 -0
  28. data/lib/rdkafka/callbacks.rb +5 -6
  29. data/lib/rdkafka/config.rb +70 -0
  30. data/lib/rdkafka/consumer/allocator.rb +0 -2
  31. data/lib/rdkafka/consumer/topic_partition_list.rb +7 -7
  32. data/lib/rdkafka/consumer.rb +133 -52
  33. data/lib/rdkafka/defaults.rb +15 -6
  34. data/lib/rdkafka/helpers/message_build_error.rb +30 -0
  35. data/lib/rdkafka/native_kafka.rb +136 -41
  36. data/lib/rdkafka/producer/partition_count_cache.rb +258 -0
  37. data/lib/rdkafka/producer.rb +196 -81
  38. data/lib/rdkafka/share_consumer.rb +75 -38
  39. data/lib/rdkafka/version.rb +1 -1
  40. data/lib/rdkafka.rb +6 -2
  41. data/package-lock.json +3 -3
  42. data/renovate.json +32 -2
  43. metadata +7 -31
  44. data/lib/rdkafka/producer/partitions_count_cache.rb +0 -212
data/renovate.json CHANGED
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "bundler": {
3
- "managerFilePatterns": ["/(^|/)Gemfile\\.lint$/"]
3
+ "managerFilePatterns": [
4
+ "/(^|/)Gemfile\\.lint$/"
5
+ ]
4
6
  },
5
7
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
6
8
  "extends": [
@@ -97,6 +99,26 @@
97
99
  "ruby/setup-ruby"
98
100
  ],
99
101
  "minimumReleaseAge": "5 days"
102
+ },
103
+ {
104
+ "description": "Keep the ubuntu:22.04 build container of the precompiled gnu libraries; a newer Ubuntu raises their glibc floor",
105
+ "matchDatasources": [
106
+ "docker"
107
+ ],
108
+ "matchPackageNames": [
109
+ "ubuntu"
110
+ ],
111
+ "matchFileNames": [
112
+ ".github/workflows/**"
113
+ ],
114
+ "allowedVersions": "/^22\\.04$/"
115
+ },
116
+ {
117
+ "description": "Major updates stay manual",
118
+ "matchUpdateTypes": [
119
+ "major"
120
+ ],
121
+ "automerge": false
100
122
  }
101
123
  ],
102
124
  "labels": [
@@ -107,5 +129,13 @@
107
129
  "schedule": [
108
130
  "before 4am on the first day of the month"
109
131
  ]
110
- }
132
+ },
133
+ "automerge": true,
134
+ "platformAutomerge": true,
135
+ "vulnerabilityAlerts": {
136
+ "labels": [
137
+ "security"
138
+ ]
139
+ },
140
+ "osvVulnerabilityAlerts": true
111
141
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: karafka-rdkafka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.0
4
+ version: 0.32.1
5
5
  platform: aarch64-linux-gnu
6
6
  authors:
7
7
  - Thijs Cadier
@@ -52,34 +52,6 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: mini_portile2
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '2.6'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '2.6'
69
- - !ruby/object:Gem::Dependency
70
- name: rake
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">"
74
- - !ruby/object:Gem::Version
75
- version: '12'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">"
81
- - !ruby/object:Gem::Version
82
- version: '12'
83
55
  description: Modern Kafka client library for Ruby based on librdkafka
84
56
  email:
85
57
  - contact@karafka.io
@@ -133,6 +105,8 @@ files:
133
105
  - lib/rdkafka/admin/describe_topics_report.rb
134
106
  - lib/rdkafka/admin/incremental_alter_configs_handle.rb
135
107
  - lib/rdkafka/admin/incremental_alter_configs_report.rb
108
+ - lib/rdkafka/admin/list_consumer_group_offsets_handle.rb
109
+ - lib/rdkafka/admin/list_consumer_group_offsets_report.rb
136
110
  - lib/rdkafka/admin/list_consumer_groups_handle.rb
137
111
  - lib/rdkafka/admin/list_consumer_groups_report.rb
138
112
  - lib/rdkafka/admin/list_offsets_handle.rb
@@ -170,6 +144,7 @@ files:
170
144
  - lib/rdkafka/callbacks/describe_consumer_groups_handler.rb
171
145
  - lib/rdkafka/callbacks/describe_topics_handler.rb
172
146
  - lib/rdkafka/callbacks/incremental_alter_configs_handler.rb
147
+ - lib/rdkafka/callbacks/list_consumer_group_offsets_handler.rb
173
148
  - lib/rdkafka/callbacks/list_consumer_groups_handler.rb
174
149
  - lib/rdkafka/callbacks/list_offsets_handler.rb
175
150
  - lib/rdkafka/clients.rb
@@ -183,6 +158,7 @@ files:
183
158
  - lib/rdkafka/defaults.rb
184
159
  - lib/rdkafka/error.rb
185
160
  - lib/rdkafka/helpers/list_offsets.rb
161
+ - lib/rdkafka/helpers/message_build_error.rb
186
162
  - lib/rdkafka/helpers/metadata.rb
187
163
  - lib/rdkafka/helpers/oauth.rb
188
164
  - lib/rdkafka/helpers/time.rb
@@ -191,7 +167,7 @@ files:
191
167
  - lib/rdkafka/producer.rb
192
168
  - lib/rdkafka/producer/delivery_handle.rb
193
169
  - lib/rdkafka/producer/delivery_report.rb
194
- - lib/rdkafka/producer/partitions_count_cache.rb
170
+ - lib/rdkafka/producer/partition_count_cache.rb
195
171
  - lib/rdkafka/producer/testing.rb
196
172
  - lib/rdkafka/share_consumer.rb
197
173
  - lib/rdkafka/share_consumer/message.rb
@@ -227,5 +203,5 @@ rubygems_version: 4.0.20
227
203
  specification_version: 4
228
204
  summary: The rdkafka gem is a modern Kafka client library for Ruby based on librdkafka.
229
205
  It wraps the production-ready C client using the ffi gem and targets Kafka 1.0+
230
- and Ruby 2.7+.
206
+ and Ruby 3.3+.
231
207
  test_files: []
@@ -1,212 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Rdkafka
4
- class Producer
5
- # Caching mechanism for Kafka topic partition counts to avoid frequent cluster queries
6
- #
7
- # This cache is designed to optimize the process of obtaining partition counts for topics.
8
- # It uses several strategies to minimize Kafka cluster queries:
9
- #
10
- # @note Design considerations:
11
- #
12
- # 1. Statistics-based updates
13
- # When statistics callbacks are enabled (via `statistics.interval.ms`), we leverage
14
- # this data to proactively update the partition counts cache. This approach costs
15
- # approximately 0.02ms of processing time during each statistics interval (typically
16
- # every 5 seconds) but eliminates the need for explicit blocking metadata queries.
17
- #
18
- # 2. Edge case handling
19
- # If a user configures `statistics.interval.ms` much higher than the default cache TTL
20
- # ({Defaults::PARTITIONS_COUNT_CACHE_TTL_MS}ms), the cache will still function correctly.
21
- # When statistics updates don't occur frequently enough, the cache entries will expire
22
- # naturally, triggering a blocking refresh when needed.
23
- #
24
- # 3. User configuration awareness
25
- # The cache respects user-defined settings. If `topic.metadata.refresh.interval.ms` is
26
- # set very high, the responsibility for potentially stale data falls on the user. This
27
- # is an explicit design choice to honor user configuration preferences and align with
28
- # librdkafka settings.
29
- #
30
- # 4. Process-wide efficiency
31
- # Since this cache is shared across all Rdkafka producers and consumers within a process,
32
- # having multiple clients improves overall efficiency. Each client contributes to keeping
33
- # the cache updated, benefiting all other clients.
34
- #
35
- # 5. Thread-safety approach
36
- # The implementation uses fine-grained locking with per-topic mutexes to minimize
37
- # contention in multi-threaded environments while ensuring data consistency.
38
- #
39
- # 6. Topic recreation handling
40
- # If a topic is deleted and recreated with fewer partitions, the cache keeps reporting the
41
- # higher count only until the entry's TTL expires. The first refresh after expiry performs
42
- # an authoritative metadata read and adopts the lower count. Within the TTL window a lower
43
- # value is still ignored, so a transient or racy lower read cannot clobber a correct higher
44
- # count.
45
- class PartitionsCountCache
46
- include Helpers::Time
47
-
48
- # Creates a new partition count cache
49
- #
50
- # @param ttl [Integer, nil] DEPRECATED: Use ttl_ms instead.
51
- # Time-to-live in seconds for cached values. Will be removed in v1.0.0.
52
- # @param ttl_ms [Integer, nil] Time-to-live in milliseconds for cached values.
53
- # Defaults to {Defaults::PARTITIONS_COUNT_CACHE_TTL_MS}.
54
- def initialize(ttl = :not_provided, ttl_ms: :not_provided)
55
- @counts = {}
56
- @mutex_hash = {}
57
- # Used only for @mutex_hash access to ensure thread-safety when creating new mutexes
58
- @mutex_for_hash = Mutex.new
59
-
60
- # Determine which TTL value to use
61
- if ttl != :not_provided && ttl_ms != :not_provided
62
- warn "DEPRECATION WARNING: Both ttl and ttl_ms were provided to PartitionsCountCache. " \
63
- "Using ttl_ms. The ttl parameter is deprecated and will be removed in v1.0.0."
64
- @ttl_ms = ttl_ms
65
- elsif ttl != :not_provided
66
- warn "DEPRECATION WARNING: ttl (seconds) parameter for PartitionsCountCache is deprecated. " \
67
- "Use ttl_ms (milliseconds) instead. This parameter will be removed in v1.0.0."
68
- @ttl_ms = (ttl * 1000).to_i
69
- elsif ttl_ms == :not_provided
70
- @ttl_ms = Defaults::PARTITIONS_COUNT_CACHE_TTL_MS
71
- else
72
- @ttl_ms = ttl_ms
73
- end
74
- end
75
-
76
- # Reads partition count for a topic with automatic refresh when expired
77
- #
78
- # This method will return the cached partition count if available and not expired.
79
- # If the value is expired or not available, it will execute the provided block
80
- # to fetch the current value from Kafka.
81
- #
82
- # @param topic [String] Kafka topic name
83
- # @yield Block that returns the current partition count when cache needs refreshing
84
- # @yieldreturn [Integer] Current partition count retrieved from Kafka
85
- # @return [Integer] Partition count for the topic
86
- #
87
- # @note The implementation prioritizes read performance over write consistency
88
- # since partition counts typically only increase during normal operation.
89
- def get(topic)
90
- current_info = @counts[topic]
91
-
92
- if current_info.nil? || expired?(current_info[0])
93
- # The cached entry is missing or expired, so the block performs an authoritative metadata
94
- # read. We hand it to `set`, which adopts a higher count always and a lower count once the
95
- # entry has expired (e.g. the topic was recreated with fewer partitions). We then return
96
- # whatever `set` settled on so a concurrent refresh that wrote a higher value still wins.
97
- new_count = yield
98
- set(topic, new_count)
99
-
100
- return @counts[topic][1]
101
- end
102
-
103
- current_info[1]
104
- end
105
-
106
- # Update partition count for a topic when needed
107
- #
108
- # This method updates the partition count for a topic in the cache.
109
- # It uses a mutex to ensure thread-safety during updates.
110
- #
111
- # @param topic [String] Kafka topic name
112
- # @param new_count [Integer] New partition count value
113
- #
114
- # @note We prioritize higher partition counts and only accept them when using
115
- # a mutex to ensure consistency. This design decision is based on the fact that
116
- # partition counts in Kafka only increase during normal operation.
117
- def set(topic, new_count)
118
- # First check outside mutex to avoid unnecessary locking
119
- current_info = @counts[topic]
120
-
121
- # Within the TTL window a lower value is treated as a stale/racy read and ignored, since
122
- # partition counts only grow during normal operation. Once the entry has expired a lower
123
- # value is an authoritative refresh (e.g. the topic was recreated with fewer partitions),
124
- # so we fall through and adopt it below.
125
- if current_info && new_count < current_info[1] && !expired?(current_info[0])
126
- refresh_timestamp(topic)
127
-
128
- return
129
- end
130
-
131
- # Only lock the specific topic mutex
132
- mutex_for(topic).synchronize do
133
- # Check again inside the lock as another thread might have updated
134
- current_info = @counts[topic]
135
-
136
- if current_info.nil?
137
- # Create new entry
138
- @counts[topic] = [monotonic_now_ms, new_count]
139
- elsif new_count > current_info[1] || expired?(current_info[0])
140
- # A higher count always wins; a lower count is accepted only when the existing entry
141
- # has expired, so a concurrent fresh higher value (which reset the timestamp) is never
142
- # clobbered by a stale lower one.
143
- current_info[0] = monotonic_now_ms
144
- current_info[1] = new_count
145
- else
146
- # Same or lower count within the TTL window: refresh the timestamp only
147
- current_info[0] = monotonic_now_ms
148
- end
149
- end
150
- end
151
-
152
- # @return [Hash] hash with ttls and partitions counts array
153
- def to_h
154
- @counts
155
- end
156
-
157
- private
158
-
159
- # Get or create a mutex for a specific topic
160
- #
161
- # This method ensures that each topic has its own mutex,
162
- # allowing operations on different topics to proceed in parallel.
163
- #
164
- # @param topic [String] Kafka topic name
165
- # @return [Mutex] Mutex for the specified topic
166
- #
167
- # @note We use a separate mutex (@mutex_for_hash) to protect the creation
168
- # of new topic mutexes. This pattern allows fine-grained locking while
169
- # maintaining thread-safety.
170
- def mutex_for(topic)
171
- mutex = @mutex_hash[topic]
172
-
173
- return mutex if mutex
174
-
175
- # Use a separate mutex to protect the creation of new topic mutexes
176
- @mutex_for_hash.synchronize do
177
- # Check again in case another thread created it
178
- @mutex_hash[topic] ||= Mutex.new
179
- end
180
-
181
- @mutex_hash[topic]
182
- end
183
-
184
- # Update the timestamp without acquiring the mutex
185
- #
186
- # This is an optimization that allows refreshing the TTL of existing entries
187
- # without the overhead of mutex acquisition.
188
- #
189
- # @param topic [String] Kafka topic name
190
- #
191
- # @note This method is safe for refreshing existing data regardless of count
192
- # because it only updates the timestamp, which doesn't affect the correctness
193
- # of concurrent operations.
194
- def refresh_timestamp(topic)
195
- current_info = @counts[topic]
196
-
197
- return unless current_info
198
-
199
- # Update the timestamp in-place
200
- current_info[0] = monotonic_now_ms
201
- end
202
-
203
- # Check if a timestamp has expired based on the TTL
204
- #
205
- # @param timestamp [Integer] Monotonic timestamp in milliseconds to check
206
- # @return [Boolean] true if expired, false otherwise
207
- def expired?(timestamp)
208
- monotonic_now_ms - timestamp > @ttl_ms
209
- end
210
- end
211
- end
212
- end