karafka-rdkafka 0.28.0-aarch64-linux-gnu → 0.28.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.
@@ -13,6 +13,14 @@ module Rdkafka
13
13
  def initialize(inner, run_polling_thread:, opaque:, auto_start: true, timeout_ms: Defaults::NATIVE_KAFKA_POLL_TIMEOUT_MS)
14
14
  @inner = inner
15
15
  @opaque = opaque
16
+ # Process that owns `@inner`. librdkafka is not fork-safe: `fork` copies only the calling
17
+ # thread, so the background/broker threads backing this handle do not exist in a child
18
+ # process. An inherited handle therefore must not be polled or destroyed in the child -
19
+ # `rd_kafka_destroy` would walk thread state that no longer exists (segfault) and the
20
+ # inherited mutexes may have been copied in a locked state (deadlock). We record the creator
21
+ # pid so a forked child can recognise an inherited handle and leave its teardown to the
22
+ # parent, which still owns the running threads.
23
+ @creator_pid = Process.pid
16
24
  # Lock around external access
17
25
  @access_mutex = Mutex.new
18
26
  # Lock around internal polling
@@ -116,17 +124,21 @@ module Rdkafka
116
124
  end
117
125
 
118
126
  # Returns whether this native Kafka handle is closed or closing
127
+ #
128
+ # A handle inherited across `fork` is reported as closed in the child: it belongs to another
129
+ # process whose threads back the native client, so it is not usable here and must not be
130
+ # destroyed here (see the `@creator_pid` note in `#initialize`). This makes every `#close`
131
+ # path - including the GC finalizers that run during a child's exit - skip the native teardown
132
+ # for inherited handles, which is what would otherwise segfault the child.
133
+ #
119
134
  # @return [Boolean] true if closed or closing
120
135
  def closed?
121
- @closing || @inner.nil?
136
+ @closing || @inner.nil? || @creator_pid != Process.pid
122
137
  end
123
138
 
124
139
  # Enable IO event notifications on the main queue
125
140
  # Librdkafka will write to your FD when the queue transitions from empty to non-empty
126
141
  #
127
- # @note This method is incompatible with background polling threads.
128
- # If background polling is enabled, use manual polling instead (e.g., consumer.poll)
129
- #
130
142
  # @param fd [Integer] your file descriptor (from IO.pipe or eventfd)
131
143
  # @param payload [String] data to write to fd when queue has data (default: "\x01")
132
144
  # @return [nil]
@@ -143,6 +155,8 @@ module Rdkafka
143
155
  # if readable
144
156
  # consumer.poll(0) # Get messages
145
157
  # end
158
+ # @note This method is incompatible with background polling threads.
159
+ # If background polling is enabled, use manual polling instead (e.g., consumer.poll)
146
160
  def enable_main_queue_io_events(fd, payload = "\x01")
147
161
  if @run_polling_thread
148
162
  raise "Cannot enable IO events while background polling thread is active. " \
@@ -160,14 +174,13 @@ module Rdkafka
160
174
  # Enable IO event notifications on the background queue
161
175
  # Librdkafka will write to your FD when the background queue transitions from empty to non-empty
162
176
  #
163
- # @note This method is incompatible with background polling threads.
164
- # If background polling is enabled, use manual polling instead (e.g., consumer.poll)
165
- #
166
177
  # @param fd [Integer] your file descriptor (from IO.pipe or eventfd)
167
178
  # @param payload [String] data to write to fd when queue has data (default: "\x01")
168
179
  # @return [nil]
169
180
  # @raise [ClosedInnerError] when the handle is closed
170
181
  # @raise [RuntimeError] when background polling thread is active
182
+ # @note This method is incompatible with background polling threads.
183
+ # If background polling is enabled, use manual polling instead (e.g., consumer.poll)
171
184
  def enable_background_queue_io_events(fd, payload = "\x01")
172
185
  if @run_polling_thread
173
186
  raise "Cannot enable IO events while background polling thread is active. " \
@@ -2,8 +2,7 @@
2
2
 
3
3
  module Rdkafka
4
4
  class Producer
5
- # Handle to wait for a delivery report which is returned when
6
- # producing a message.
5
+ # Handle to wait for a delivery report which is returned when producing a message.
7
6
  class DeliveryHandle < Rdkafka::AbstractHandle
8
7
  layout :pending, :bool,
9
8
  :response, :int,
@@ -36,7 +36,8 @@ module Rdkafka
36
36
  # Checks if a fatal error has occurred and retrieves error details.
37
37
  # Calls rd_kafka_fatal_error to get the actual fatal error code and message.
38
38
  #
39
- # @return [Hash, nil] Hash with :error_code and :error_string if fatal error occurred, nil otherwise
39
+ # @return [Hash, nil] Hash with :error_code and :error_string if fatal error occurred,
40
+ # nil otherwise
40
41
  #
41
42
  # @example
42
43
  # if fatal_error = producer.fatal_error
@@ -1,13 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rdkafka
4
- # A producer for Kafka messages. To create a producer set up a {Config} and call {Config#producer producer} on that.
4
+ # A producer for Kafka messages. To create a producer set up a {Config} and call
5
+ # {Config#producer producer} on that.
5
6
  class Producer
6
7
  include Helpers::Time
7
8
  include Helpers::OAuth
8
9
  include Helpers::Metadata
9
10
 
10
- # @private
11
+ # @!visibility private
11
12
  @@partitions_count_cache = PartitionsCountCache.new
12
13
 
13
14
  # Global (process wide) partitions cache. We use it to store number of topics partitions,
@@ -175,8 +176,7 @@ module Rdkafka
175
176
  end
176
177
  end
177
178
 
178
- # Begin a new transaction
179
- # Requires {#init_transactions} to have been called first
179
+ # Begin a new transaction. Requires {#init_transactions} to have been called first
180
180
  #
181
181
  # @return [true] Returns true on success
182
182
  # @raise [RdkafkaError] if beginning the transaction fails
@@ -331,10 +331,9 @@ module Rdkafka
331
331
  # @return [Integer] the number of messages in the queue
332
332
  # @raise [Rdkafka::ClosedProducerError] if called on a closed producer
333
333
  #
334
- # @note This method is thread-safe as it uses the @native_kafka.with_inner synchronization
335
- #
336
334
  # @example
337
335
  # producer.queue_size #=> 42
336
+ # @note This method is thread-safe as it uses the @native_kafka.with_inner synchronization
338
337
  def queue_size
339
338
  closed_producer_check(__method__)
340
339
 
@@ -360,10 +359,6 @@ module Rdkafka
360
359
  # @return [nil]
361
360
  # @raise [Rdkafka::ClosedProducerError] if called on a closed producer
362
361
  #
363
- # @note This method holds the inner lock until the queue is empty or `:stop` is returned.
364
- # Other producer operations (produce, close, etc.) will wait until this method returns.
365
- # @note This method is thread-safe as it uses @native_kafka.with_inner synchronization
366
- #
367
362
  # @example Drain all pending callbacks
368
363
  # producer.events_poll_nb_each { |_count| }
369
364
  #
@@ -372,6 +367,9 @@ module Rdkafka
372
367
  # producer.events_poll_nb_each do |_count|
373
368
  # :stop if monotonic_now >= deadline
374
369
  # end
370
+ # @note This method holds the inner lock until the queue is empty or `:stop` is returned.
371
+ # Other producer operations (produce, close, etc.) will wait until this method returns.
372
+ # @note This method is thread-safe as it uses @native_kafka.with_inner synchronization
375
373
  def events_poll_nb_each
376
374
  closed_producer_check(__method__)
377
375
 
@@ -387,7 +385,8 @@ module Rdkafka
387
385
  # Partition count for a given topic.
388
386
  #
389
387
  # @param topic [String] The topic name.
390
- # @return [Integer] partition count for a given topic or `RD_KAFKA_PARTITION_UA (-1)` if it could not be obtained.
388
+ # @return [Integer] partition count for a given topic or `RD_KAFKA_PARTITION_UA (-1)` if it
389
+ # could not be obtained.
391
390
  #
392
391
  # @note If 'allow.auto.create.topics' is set to true in the broker, the topic will be
393
392
  # auto-created after returning nil.
@@ -422,23 +421,32 @@ module Rdkafka
422
421
  end
423
422
  end
424
423
 
425
- # Produces a message to a Kafka topic. The message is added to rdkafka's queue, call {DeliveryHandle#wait wait} on the returned delivery handle to make sure it is delivered.
424
+ # Produces a message to a Kafka topic. The message is added to rdkafka's queue, call
425
+ # {DeliveryHandle#wait wait} on the returned delivery handle to make sure it is delivered.
426
426
  #
427
- # When no partition is specified the underlying Kafka library picks a partition based on the key. If no key is specified, a random partition will be used.
428
- # When a timestamp is provided this is used instead of the auto-generated timestamp.
427
+ # When no partition is specified the underlying Kafka library picks a partition based on the
428
+ # key. If no key is specified, a random partition will be used. When a timestamp is provided
429
+ # this is used instead of the auto-generated timestamp.
429
430
  #
430
431
  # @param topic [String] The topic to produce to
431
432
  # @param payload [String, nil]
432
433
  # @param key [String, nil]
433
434
  # @param partition [Integer, nil] Optional partition to produce to
434
- # @param partition_key [String, nil] Optional partition key based on which partition assignment can happen
435
- # @param timestamp [Time, Integer, nil] Optional timestamp of this message. Integer timestamp is in milliseconds since Jan 1 1970.
436
- # @param headers [Hash{String => String, Array<String>}] Optional message headers. Values can be either a single string or an array of strings to support duplicate headers per KIP-82
437
- # @param label [Object, nil] a label that can be assigned when producing a message that will be part of the delivery handle and the delivery report
438
- # @param topic_config [Hash] topic config for given message dispatch. Allows to send messages to topics with different configuration
435
+ # @param partition_key [String, nil] Optional partition key based on which partition
436
+ # assignment can happen
437
+ # @param timestamp [Time, Integer, nil] Optional timestamp of this message. Integer
438
+ # timestamp is in milliseconds since Jan 1 1970.
439
+ # @param headers [Hash{String => String, Array<String>}] Optional message headers. Values
440
+ # can be either a single string or an array of strings to support duplicate headers per
441
+ # KIP-82
442
+ # @param label [Object, nil] a label that can be assigned when producing a message that
443
+ # will be part of the delivery handle and the delivery report
444
+ # @param topic_config [Hash] topic config for given message dispatch. Allows to send
445
+ # messages to topics with different configuration
439
446
  # @param partitioner [String] name of the partitioner to use
440
447
  #
441
- # @return [DeliveryHandle] Delivery handle that can be used to wait for the result of producing this message
448
+ # @return [DeliveryHandle] Delivery handle that can be used to wait for the result of
449
+ # producing this message
442
450
  #
443
451
  # @raise [RdkafkaError] When adding the message to rdkafka's queue failed
444
452
  def produce(
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Rdkafka
4
4
  # Current rdkafka-ruby gem version
5
- VERSION = "0.28.0"
5
+ VERSION = "0.28.1"
6
6
  # Target librdkafka version to be used
7
7
  LIBRDKAFKA_VERSION = "2.14.2"
8
8
  # SHA256 hash of the librdkafka source tarball for verification
data/lib/rdkafka.rb CHANGED
@@ -17,6 +17,8 @@ require "rdkafka/admin/create_topic_handle"
17
17
  require "rdkafka/admin/create_topic_report"
18
18
  require "rdkafka/admin/delete_groups_handle"
19
19
  require "rdkafka/admin/delete_groups_report"
20
+ require "rdkafka/admin/delete_records_handle"
21
+ require "rdkafka/admin/delete_records_report"
20
22
  require "rdkafka/admin/delete_topic_handle"
21
23
  require "rdkafka/admin/delete_topic_report"
22
24
  require "rdkafka/admin/create_partitions_handle"
@@ -33,6 +35,8 @@ require "rdkafka/admin/incremental_alter_configs_handle"
33
35
  require "rdkafka/admin/incremental_alter_configs_report"
34
36
  require "rdkafka/admin/list_offsets_handle"
35
37
  require "rdkafka/admin/list_offsets_report"
38
+ require "rdkafka/admin/list_consumer_groups_handle"
39
+ require "rdkafka/admin/list_consumer_groups_report"
36
40
  require "rdkafka/admin/acl_binding_result"
37
41
  require "rdkafka/admin/config_binding_result"
38
42
  require "rdkafka/admin/config_resource_binding_result"
@@ -43,12 +47,14 @@ require "rdkafka/callbacks/create_topic_handler"
43
47
  require "rdkafka/callbacks/delete_topic_handler"
44
48
  require "rdkafka/callbacks/create_partitions_handler"
45
49
  require "rdkafka/callbacks/delete_groups_handler"
50
+ require "rdkafka/callbacks/delete_records_handler"
46
51
  require "rdkafka/callbacks/create_acl_handler"
47
52
  require "rdkafka/callbacks/delete_acl_handler"
48
53
  require "rdkafka/callbacks/describe_acl_handler"
49
54
  require "rdkafka/callbacks/describe_configs_handler"
50
55
  require "rdkafka/callbacks/incremental_alter_configs_handler"
51
56
  require "rdkafka/callbacks/list_offsets_handler"
57
+ require "rdkafka/callbacks/list_consumer_groups_handler"
52
58
  require "rdkafka/config"
53
59
  require "rdkafka/consumer"
54
60
  require "rdkafka/consumer/headers"
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.28.0
4
+ version: 0.28.1
5
5
  platform: aarch64-linux-gnu
6
6
  authors:
7
7
  - Thijs Cadier
@@ -112,6 +112,8 @@ files:
112
112
  - lib/rdkafka/admin/delete_acl_report.rb
113
113
  - lib/rdkafka/admin/delete_groups_handle.rb
114
114
  - lib/rdkafka/admin/delete_groups_report.rb
115
+ - lib/rdkafka/admin/delete_records_handle.rb
116
+ - lib/rdkafka/admin/delete_records_report.rb
115
117
  - lib/rdkafka/admin/delete_topic_handle.rb
116
118
  - lib/rdkafka/admin/delete_topic_report.rb
117
119
  - lib/rdkafka/admin/describe_acl_handle.rb
@@ -120,6 +122,8 @@ files:
120
122
  - lib/rdkafka/admin/describe_configs_report.rb
121
123
  - lib/rdkafka/admin/incremental_alter_configs_handle.rb
122
124
  - lib/rdkafka/admin/incremental_alter_configs_report.rb
125
+ - lib/rdkafka/admin/list_consumer_groups_handle.rb
126
+ - lib/rdkafka/admin/list_consumer_groups_report.rb
123
127
  - lib/rdkafka/admin/list_offsets_handle.rb
124
128
  - lib/rdkafka/admin/list_offsets_report.rb
125
129
  - lib/rdkafka/bindings.rb
@@ -130,10 +134,12 @@ files:
130
134
  - lib/rdkafka/callbacks/create_topic_handler.rb
131
135
  - lib/rdkafka/callbacks/delete_acl_handler.rb
132
136
  - lib/rdkafka/callbacks/delete_groups_handler.rb
137
+ - lib/rdkafka/callbacks/delete_records_handler.rb
133
138
  - lib/rdkafka/callbacks/delete_topic_handler.rb
134
139
  - lib/rdkafka/callbacks/describe_acl_handler.rb
135
140
  - lib/rdkafka/callbacks/describe_configs_handler.rb
136
141
  - lib/rdkafka/callbacks/incremental_alter_configs_handler.rb
142
+ - lib/rdkafka/callbacks/list_consumer_groups_handler.rb
137
143
  - lib/rdkafka/callbacks/list_offsets_handler.rb
138
144
  - lib/rdkafka/config.rb
139
145
  - lib/rdkafka/consumer.rb
@@ -182,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
188
  - !ruby/object:Gem::Version
183
189
  version: '0'
184
190
  requirements: []
185
- rubygems_version: 4.0.10
191
+ rubygems_version: 4.0.16
186
192
  specification_version: 4
187
193
  summary: The rdkafka gem is a modern Kafka client library for Ruby based on librdkafka.
188
194
  It wraps the production-ready C client using the ffi gem and targets Kafka 1.0+