karafka-rdkafka 0.30.1-aarch64-linux-gnu → 0.31.0-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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +46 -27
  3. data/README.md +1 -0
  4. data/docker-compose-ssl.yml +1 -0
  5. data/docker-compose.yml +1 -0
  6. data/ext/librdkafka.so +0 -0
  7. data/karafka-rdkafka.gemspec +1 -1
  8. data/lib/rdkafka/admin/describe_cluster_handle.rb +31 -0
  9. data/lib/rdkafka/admin/describe_cluster_report.rb +48 -0
  10. data/lib/rdkafka/admin/describe_consumer_groups_handle.rb +31 -0
  11. data/lib/rdkafka/admin/describe_consumer_groups_report.rb +151 -0
  12. data/lib/rdkafka/admin/describe_result_parsing.rb +47 -0
  13. data/lib/rdkafka/admin/describe_topics_handle.rb +31 -0
  14. data/lib/rdkafka/admin/describe_topics_report.rb +118 -0
  15. data/lib/rdkafka/admin.rb +245 -0
  16. data/lib/rdkafka/bindings/admin/acls.rb +85 -0
  17. data/lib/rdkafka/bindings/admin/configs.rb +37 -0
  18. data/lib/rdkafka/bindings/admin/list_offsets.rb +26 -0
  19. data/lib/rdkafka/bindings/admin.rb +197 -0
  20. data/lib/rdkafka/bindings/callbacks.rb +148 -0
  21. data/lib/rdkafka/bindings/configuration.rb +50 -0
  22. data/lib/rdkafka/bindings/consumer.rb +83 -0
  23. data/lib/rdkafka/bindings/errors.rb +17 -0
  24. data/lib/rdkafka/bindings/handle.rb +16 -0
  25. data/lib/rdkafka/bindings/messages.rb +28 -0
  26. data/lib/rdkafka/bindings/metadata.rb +17 -0
  27. data/lib/rdkafka/bindings/polling.rb +17 -0
  28. data/lib/rdkafka/bindings/producer.rb +82 -0
  29. data/lib/rdkafka/bindings/share_consumer.rb +67 -0
  30. data/lib/rdkafka/bindings/structs.rb +62 -0
  31. data/lib/rdkafka/bindings.rb +13 -775
  32. data/lib/rdkafka/callbacks/describe_cluster_handler.rb +36 -0
  33. data/lib/rdkafka/callbacks/describe_consumer_groups_handler.rb +36 -0
  34. data/lib/rdkafka/callbacks/describe_topics_handler.rb +36 -0
  35. data/lib/rdkafka/callbacks.rb +10 -1
  36. data/lib/rdkafka/clients.rb +13 -46
  37. data/lib/rdkafka/consumer/message.rb +6 -9
  38. data/lib/rdkafka/defaults.rb +4 -0
  39. data/lib/rdkafka/producer/delivery_handle.rb +18 -16
  40. data/lib/rdkafka/producer/delivery_report.rb +51 -1
  41. data/lib/rdkafka/share_consumer.rb +54 -3
  42. data/lib/rdkafka/version.rb +3 -3
  43. data/lib/rdkafka.rb +10 -0
  44. data/package-lock.json +9 -9
  45. data/renovate.json +3 -0
  46. metadata +27 -2
@@ -90,780 +90,18 @@ module Rdkafka
90
90
  # librdkafka components without initializing the client
91
91
  # See: https://github.com/confluentinc/librdkafka/issues/4590
92
92
  attach_function :rd_kafka_global_init, [], :void
93
-
94
- # Polling
95
-
96
- attach_function :rd_kafka_flush, [:pointer, :int], :int, blocking: true
97
- attach_function :rd_kafka_poll, [:pointer, :int], :int, blocking: true
98
- attach_function :rd_kafka_outq_len, [:pointer], :int, blocking: true
99
-
100
- # Non-blocking poll variants (do not release GVL)
101
- # These are more efficient for poll(0) calls in fiber schedulers where GVL
102
- # release/reacquire overhead is wasteful since we don't expect to wait.
103
- # Uses the same underlying C function but with blocking: false to skip GVL release.
104
- attach_function :rd_kafka_poll_nb, :rd_kafka_poll, [:pointer, :int], :int, blocking: false
105
-
106
- # Metadata
107
-
108
- attach_function :rd_kafka_name, [:pointer], :string
109
- # Both return a newly allocated string the caller must release with rd_kafka_mem_free; they
110
- # are attached as :pointer (not :string) so we can free them instead of leaking. clusterid
111
- # also takes a timeout_ms (the previous arity was wrong, leaving that argument as garbage).
112
- attach_function :rd_kafka_memberid, [:pointer], :pointer, blocking: true
113
- attach_function :rd_kafka_clusterid, [:pointer, :int], :pointer, blocking: true
114
- attach_function :rd_kafka_mem_free, [:pointer, :pointer], :void
115
- attach_function :rd_kafka_metadata, [:pointer, :int, :pointer, :pointer, :int], :int, blocking: true
116
- attach_function :rd_kafka_metadata_destroy, [:pointer], :void, blocking: true
117
-
118
- # FFI struct representing a Kafka message (rd_kafka_message_t)
119
- class Message < FFI::Struct
120
- layout :err, :int,
121
- :rkt, :pointer,
122
- :partition, :int32,
123
- :payload, :pointer,
124
- :len, :size_t,
125
- :key, :pointer,
126
- :key_len, :size_t,
127
- :offset, :int64,
128
- :_private, :pointer
129
- end
130
-
131
- attach_function :rd_kafka_message_destroy, [:pointer], :void
132
- attach_function :rd_kafka_message_timestamp, [:pointer, :pointer], :int64
133
- attach_function :rd_kafka_topic_new, [:pointer, :string, :pointer], :pointer
134
- attach_function :rd_kafka_topic_destroy, [:pointer], :pointer
135
- attach_function :rd_kafka_topic_name, [:pointer], :string
136
-
137
- # FFI struct representing a topic partition (rd_kafka_topic_partition_t)
138
- class TopicPartition < FFI::Struct
139
- layout :topic, :string,
140
- :partition, :int32,
141
- :offset, :int64,
142
- :metadata, :pointer,
143
- :metadata_size, :size_t,
144
- :opaque, :pointer,
145
- :err, :int,
146
- :_private, :pointer
147
- end
148
-
149
- # FFI struct representing a topic partition list (rd_kafka_topic_partition_list_t)
150
- class TopicPartitionList < FFI::Struct
151
- layout :cnt, :int,
152
- :size, :int,
153
- :elems, :pointer
154
- end
155
-
156
- attach_function :rd_kafka_topic_partition_list_new, [:int32], :pointer
157
- attach_function :rd_kafka_topic_partition_list_add, [:pointer, :string, :int32], :pointer
158
- attach_function :rd_kafka_topic_partition_list_set_offset, [:pointer, :string, :int32, :int64], :void
159
- attach_function :rd_kafka_topic_partition_list_destroy, [:pointer], :void
160
- attach_function :rd_kafka_topic_partition_list_copy, [:pointer], :pointer
161
-
162
- # FFI struct representing a config resource (rd_kafka_ConfigResource_t)
163
- # Structs for management of configurations. Each configuration is attached to a resource
164
- # and one resource can have many configuration details. Each resource will also have
165
- # separate errors results if obtaining configuration was not possible for any reason
166
- class ConfigResource < FFI::Struct
167
- layout :type, :int,
168
- :name, :string
169
- end
170
-
171
- attach_function :rd_kafka_DescribeConfigs, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
172
- attach_function :rd_kafka_ConfigResource_new, [:int32, :pointer], :pointer
173
- attach_function :rd_kafka_ConfigResource_destroy, [:pointer], :void
174
- attach_function :rd_kafka_ConfigResource_destroy_array, [:pointer, :int32], :void
175
- attach_function :rd_kafka_event_DescribeConfigs_result, [:pointer], :pointer
176
- attach_function :rd_kafka_DescribeConfigs_result_resources, [:pointer, :pointer], :pointer
177
- attach_function :rd_kafka_ConfigResource_configs, [:pointer, :pointer], :pointer
178
- attach_function :rd_kafka_ConfigEntry_name, [:pointer], :string
179
- attach_function :rd_kafka_ConfigEntry_value, [:pointer], :string
180
- attach_function :rd_kafka_ConfigEntry_is_read_only, [:pointer], :int
181
- attach_function :rd_kafka_ConfigEntry_is_default, [:pointer], :int
182
- attach_function :rd_kafka_ConfigEntry_is_sensitive, [:pointer], :int
183
- attach_function :rd_kafka_ConfigEntry_is_synonym, [:pointer], :int
184
- attach_function :rd_kafka_ConfigEntry_synonyms, [:pointer, :pointer], :pointer
185
- attach_function :rd_kafka_ConfigResource_error, [:pointer], :int
186
- attach_function :rd_kafka_ConfigResource_error_string, [:pointer], :string
187
- attach_function :rd_kafka_IncrementalAlterConfigs, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
188
- attach_function :rd_kafka_IncrementalAlterConfigs_result_resources, [:pointer, :pointer], :pointer
189
- attach_function :rd_kafka_ConfigResource_add_incremental_config, [:pointer, :string, :int32, :string], :pointer
190
- attach_function :rd_kafka_event_IncrementalAlterConfigs_result, [:pointer], :pointer
191
-
192
- RD_KAFKA_ADMIN_OP_DESCRIBECONFIGS = 5
193
- RD_KAFKA_EVENT_DESCRIBECONFIGS_RESULT = 104
194
-
195
- RD_KAFKA_ADMIN_OP_INCREMENTALALTERCONFIGS = 16
196
- RD_KAFKA_EVENT_INCREMENTALALTERCONFIGS_RESULT = 131072
197
-
198
- RD_KAFKA_ALTER_CONFIG_OP_TYPE_SET = 0
199
- RD_KAFKA_ALTER_CONFIG_OP_TYPE_DELETE = 1
200
- RD_KAFKA_ALTER_CONFIG_OP_TYPE_APPEND = 2
201
- RD_KAFKA_ALTER_CONFIG_OP_TYPE_SUBTRACT = 3
202
-
203
- # List Offsets
204
- RD_KAFKA_ADMIN_OP_LISTOFFSETS = 21
205
- RD_KAFKA_EVENT_LISTOFFSETS_RESULT = 0x400000
206
-
207
- # rd_kafka_IsolationLevel_t
208
- RD_KAFKA_ISOLATION_LEVEL_READ_UNCOMMITTED = 0
209
- RD_KAFKA_ISOLATION_LEVEL_READ_COMMITTED = 1
210
-
211
- # rd_kafka_OffsetSpec_t
212
- RD_KAFKA_OFFSET_SPEC_MAX_TIMESTAMP = -3
213
- RD_KAFKA_OFFSET_SPEC_EARLIEST = -2
214
- RD_KAFKA_OFFSET_SPEC_LATEST = -1
215
-
216
- attach_function :rd_kafka_ListOffsets, [:pointer, :pointer, :pointer, :pointer], :void, blocking: true
217
- attach_function :rd_kafka_event_ListOffsets_result, [:pointer], :pointer
218
- attach_function :rd_kafka_ListOffsets_result_infos, [:pointer, :pointer], :pointer
219
- attach_function :rd_kafka_ListOffsetsResultInfo_topic_partition, [:pointer], :pointer
220
- attach_function :rd_kafka_ListOffsetsResultInfo_timestamp, [:pointer], :int64
221
- attach_function :rd_kafka_AdminOptions_set_isolation_level, [:pointer, :int], :pointer
222
- attach_function :rd_kafka_topic_partition_get_leader_epoch, [:pointer], :int32
223
-
224
- # FFI struct for error description (rd_kafka_err_desc)
225
- class NativeErrorDesc < FFI::Struct
226
- layout :code, :int,
227
- :name, :pointer,
228
- :desc, :pointer
229
- end
230
-
231
- attach_function :rd_kafka_err2name, [:int], :string
232
- attach_function :rd_kafka_err2str, [:int], :string
233
- attach_function :rd_kafka_error_is_fatal, [:pointer], :int
234
- attach_function :rd_kafka_error_is_retriable, [:pointer], :int
235
- attach_function :rd_kafka_error_txn_requires_abort, [:pointer], :int
236
- attach_function :rd_kafka_error_destroy, [:pointer], :void
237
- attach_function :rd_kafka_get_err_descs, [:pointer, :pointer], :void
238
- attach_function :rd_kafka_fatal_error, [:pointer, :pointer, :int], :int
239
- attach_function :rd_kafka_test_fatal_error, [:pointer, :int, :string], :int
240
-
241
- # Configuration
242
-
243
- enum :kafka_config_response, [
244
- :config_unknown, -2,
245
- :config_invalid, -1,
246
- :config_ok, 0
247
- ]
248
-
249
- attach_function :rd_kafka_conf_new, [], :pointer
250
- attach_function :rd_kafka_conf_set, [:pointer, :string, :string, :pointer, :int], :kafka_config_response
251
- attach_function :rd_kafka_conf_get, [:pointer, :string, :pointer, :pointer], :kafka_config_response
252
- attach_function :rd_kafka_conf, [:pointer], :pointer
253
- attach_function :rd_kafka_conf_dump, [:pointer, :pointer], :pointer
254
- attach_function :rd_kafka_conf_dump_free, [:pointer, :size_t], :void
255
- attach_function :rd_kafka_conf_destroy, [:pointer], :void
256
- callback :log_cb, [:pointer, :int, :string, :string], :void
257
- attach_function :rd_kafka_conf_set_log_cb, [:pointer, :log_cb], :void
258
- attach_function :rd_kafka_conf_set_opaque, [:pointer, :pointer], :void
259
- callback :stats_cb, [:pointer, :string, :int, :pointer], :int
260
- attach_function :rd_kafka_conf_set_stats_cb, [:pointer, :stats_cb], :void
261
- callback :error_cb, [:pointer, :int, :string, :pointer], :void
262
- attach_function :rd_kafka_conf_set_error_cb, [:pointer, :error_cb], :void
263
- attach_function :rd_kafka_rebalance_protocol, [:pointer], :string
264
- callback :oauthbearer_token_refresh_cb, [:pointer, :string, :pointer], :void
265
- attach_function :rd_kafka_conf_set_oauthbearer_token_refresh_cb, [:pointer, :oauthbearer_token_refresh_cb], :void
266
- attach_function :rd_kafka_oauthbearer_set_token, [:pointer, :string, :int64, :pointer, :pointer, :int, :pointer, :int], :int
267
- attach_function :rd_kafka_oauthbearer_set_token_failure, [:pointer, :string], :int
268
- # Log queue
269
- attach_function :rd_kafka_set_log_queue, [:pointer, :pointer], :void
270
- attach_function :rd_kafka_queue_get_main, [:pointer], :pointer
271
- attach_function :rd_kafka_queue_get_background, [:pointer], :pointer
272
-
273
- # Queue IO Event Support - for fiber scheduler integration
274
- # Enables notifications to a custom FD when queue transitions from empty to non-empty
275
- # Arguments:
276
- # - queue (rd_kafka_queue_t*) - the queue to monitor
277
- # - fd (int) - file descriptor to write to (provide your own pipe/eventfd)
278
- # - payload (const void*) - data to write to fd
279
- # - size (size_t) - size of payload
280
- attach_function :rd_kafka_queue_io_event_enable, [:pointer, :int, :pointer, :size_t], :void
281
- # Per topic configs
282
- attach_function :rd_kafka_topic_conf_new, [], :pointer
283
- attach_function :rd_kafka_topic_conf_destroy, [:pointer], :void
284
- attach_function :rd_kafka_topic_conf_set, [:pointer, :string, :string, :pointer, :int], :kafka_config_response
285
-
286
- LogCallback = FFI::Function.new(
287
- :void, [:pointer, :int, :string, :string]
288
- ) do |_client_ptr, level, _level_string, line|
289
- severity = case level
290
- when 0, 1, 2
291
- Logger::FATAL
292
- when 3
293
- Logger::ERROR
294
- when 4
295
- Logger::WARN
296
- when 5, 6
297
- Logger::INFO
298
- when 7
299
- Logger::DEBUG
300
- else
301
- Logger::UNKNOWN
302
- end
303
-
304
- Rdkafka::Config.ensure_log_thread
305
- Rdkafka::Config.log_queue << [severity, "rdkafka: #{line}"]
306
- end
307
-
308
- StatsCallback = FFI::Function.new(
309
- :int, [:pointer, :string, :int, :pointer]
310
- ) do |_client_ptr, json, _json_len, _opaque|
311
- if Rdkafka::Config.statistics_callback
312
- stats = JSON.parse(json)
313
-
314
- # If user requested statistics callbacks, we can use the statistics data to get the
315
- # partitions count for each topic when this data is published. That way we do not have
316
- # to query this information when user is using `partition_key`. This takes around 0.02ms
317
- # every statistics interval period (most likely every 5 seconds) and saves us from making
318
- # any queries to the cluster for the partition count.
319
- #
320
- # One edge case is if user would set the `statistics.interval.ms` much higher than the
321
- # default current partition count refresh (30 seconds). This is taken care of as the lack
322
- # of reporting to the partitions cache will cause cache expire and blocking refresh.
323
- #
324
- # If user sets `topic.metadata.refresh.interval.ms` too high this is on the user.
325
- #
326
- # Since this cache is shared, having few consumers and/or producers in one process will
327
- # automatically improve the querying times even with low refresh times.
328
- (stats["topics"] || EMPTY_HASH).each do |topic_name, details|
329
- partitions_count = details["partitions"].keys.count { |k| !(k == RD_KAFKA_PARTITION_UA_STR) }
330
-
331
- next unless partitions_count.positive?
332
-
333
- Rdkafka::Producer.partitions_count_cache.set(topic_name, partitions_count)
334
- end
335
-
336
- Rdkafka::Config.statistics_callback.call(stats)
337
- end
338
-
339
- # Return 0 so librdkafka frees the json string
340
- RD_KAFKA_RESP_ERR_NO_ERROR
341
- end
342
-
343
- # Retrieves fatal error details from a kafka client handle.
344
- # This is a helper method to extract fatal error information consistently
345
- # across different parts of the codebase (callbacks, testing utilities, etc.).
346
- #
347
- # @param client_ptr [FFI::Pointer] Native kafka client pointer
348
- # @return [Hash, nil] Hash with :error_code and :error_string if fatal error occurred,
349
- # nil otherwise
350
- #
351
- # @example
352
- # details = Rdkafka::Bindings.extract_fatal_error(client_ptr)
353
- # if details
354
- # puts "Fatal error #{details[:error_code]}: #{details[:error_string]}"
355
- # end
356
- def self.extract_fatal_error(client_ptr)
357
- error_buffer = FFI::MemoryPointer.new(:char, FATAL_ERROR_BUFFER_SIZE)
358
-
359
- error_code = rd_kafka_fatal_error(client_ptr, error_buffer, FATAL_ERROR_BUFFER_SIZE)
360
-
361
- return nil if error_code == RD_KAFKA_RESP_ERR_NO_ERROR
362
-
363
- {
364
- error_code: error_code,
365
- error_string: error_buffer.read_string
366
- }
367
- end
368
-
369
- ErrorCallback = FFI::Function.new(
370
- :void, [:pointer, :int, :string, :pointer]
371
- ) do |client_ptr, err_code, reason, _opaque|
372
- if Rdkafka::Config.error_callback
373
- instance_name = client_ptr.null? ? nil : Rdkafka::Bindings.rd_kafka_name(client_ptr)
374
-
375
- # Handle fatal errors according to librdkafka documentation:
376
- # When ERR__FATAL is received, we must call rd_kafka_fatal_error()
377
- # to get the actual underlying fatal error code and description.
378
- error = if err_code == RD_KAFKA_RESP_ERR__FATAL
379
- Rdkafka::RdkafkaError.build_fatal(
380
- client_ptr,
381
- fallback_error_code: err_code,
382
- fallback_message: reason,
383
- instance_name: instance_name
384
- )
385
- else
386
- Rdkafka::RdkafkaError.build(err_code, broker_message: reason, instance_name: instance_name)
387
- end
388
-
389
- error.set_backtrace(caller)
390
- Rdkafka::Config.error_callback.call(error)
391
- end
392
- end
393
-
394
- # The OAuth callback is currently global and contextless. This means that the callback will be
395
- # called for all instances, and the callback must be able to determine to which instance it is
396
- # associated. The instance name will be provided in the callback, allowing the callback to
397
- # reference the correct instance.
398
- #
399
- # An example of how to use the instance name in the callback is given below.
400
- # The `refresh_token` is configured as the `oauthbearer_token_refresh_callback`.
401
- # `instances` is a map of client names to client instances, maintained by the user.
402
- #
403
- # ```
404
- # def refresh_token(config, client_name)
405
- # client = instances[client_name]
406
- # client.oauthbearer_set_token(
407
- # token: 'new-token-value',
408
- # lifetime_ms: token-lifetime-ms,
409
- # principal_name: 'principal-name'
410
- # )
411
- # end
412
- # ```
413
- OAuthbearerTokenRefreshCallback = FFI::Function.new(
414
- :void, [:pointer, :string, :pointer]
415
- ) do |client_ptr, config, opaque_ptr|
416
- if Rdkafka::Config.oauthbearer_token_refresh_callback && !client_ptr.null?
417
- client_name = Rdkafka::Bindings.rd_kafka_name(client_ptr)
418
-
419
- # Share consumers have no way to query their librdkafka client name (the share handle
420
- # exposes no name accessor), so hand it over here - where librdkafka provides it -
421
- # letting applications correlate this callback's client name with a ShareConsumer via
422
- # ShareConsumer#name.
423
- Rdkafka::Config.opaques[opaque_ptr.to_i]&.capture_client_name(client_name)
424
-
425
- Rdkafka::Config.oauthbearer_token_refresh_callback.call(config, client_name)
426
- end
427
- end
428
-
429
- # Handle
430
-
431
- enum :kafka_type, [
432
- :rd_kafka_producer,
433
- :rd_kafka_consumer
434
- ]
435
-
436
- attach_function :rd_kafka_new, [:kafka_type, :pointer, :pointer, :int], :pointer
437
-
438
- attach_function :rd_kafka_destroy, [:pointer], :void
439
-
440
- # Consumer
441
-
442
- attach_function :rd_kafka_subscribe, [:pointer, :pointer], :int, blocking: true
443
- attach_function :rd_kafka_unsubscribe, [:pointer], :int, blocking: true
444
- attach_function :rd_kafka_subscription, [:pointer, :pointer], :int, blocking: true
445
- attach_function :rd_kafka_assign, [:pointer, :pointer], :int, blocking: true
446
- attach_function :rd_kafka_incremental_assign, [:pointer, :pointer], :int, blocking: true
447
- attach_function :rd_kafka_incremental_unassign, [:pointer, :pointer], :int, blocking: true
448
- attach_function :rd_kafka_assignment, [:pointer, :pointer], :int, blocking: true
449
- attach_function :rd_kafka_assignment_lost, [:pointer], :int, blocking: true
450
- attach_function :rd_kafka_committed, [:pointer, :pointer, :int], :int, blocking: true
451
- attach_function :rd_kafka_commit, [:pointer, :pointer, :bool], :int, blocking: true
452
- attach_function :rd_kafka_poll_set_consumer, [:pointer], :void, blocking: true
453
- attach_function :rd_kafka_consumer_poll, [:pointer, :int], :pointer, blocking: true
454
- # Non-blocking consumer poll variant (does not release GVL)
455
- # More efficient for poll(0) calls in fiber schedulers.
456
- attach_function :rd_kafka_consumer_poll_nb, :rd_kafka_consumer_poll, [:pointer, :int], :pointer, blocking: false
457
- attach_function :rd_kafka_consumer_close, [:pointer], :void, blocking: true
458
- attach_function :rd_kafka_queue_get_consumer, [:pointer], :pointer
459
- attach_function :rd_kafka_consume_batch_queue, [:pointer, :int, :pointer, :size_t], :ssize_t, blocking: true
460
- attach_function :rd_kafka_consume_batch_queue_nb, :rd_kafka_consume_batch_queue, [:pointer, :int, :pointer, :size_t], :ssize_t, blocking: false
461
- attach_function :rd_kafka_offsets_store, [:pointer, :pointer], :int, blocking: true
462
- attach_function :rd_kafka_pause_partitions, [:pointer, :pointer], :int, blocking: true
463
- attach_function :rd_kafka_resume_partitions, [:pointer, :pointer], :int, blocking: true
464
- attach_function :rd_kafka_seek, [:pointer, :int32, :int64, :int], :int, blocking: true
465
- attach_function :rd_kafka_offsets_for_times, [:pointer, :pointer, :int], :int, blocking: true
466
- attach_function :rd_kafka_position, [:pointer, :pointer], :int, blocking: true
467
- # those two are used for eos support
468
- attach_function :rd_kafka_consumer_group_metadata, [:pointer], :pointer, blocking: true
469
- attach_function :rd_kafka_consumer_group_metadata_destroy, [:pointer], :void, blocking: true
470
-
471
- # Headers
472
- attach_function :rd_kafka_header_get_all, [:pointer, :size_t, :pointer, :pointer, SizePtr], :int
473
- attach_function :rd_kafka_message_headers, [:pointer, :pointer], :int
474
-
475
- # Rebalance
476
-
477
- callback :rebalance_cb_function, [:pointer, :int, :pointer, :pointer], :void
478
- attach_function :rd_kafka_conf_set_rebalance_cb, [:pointer, :rebalance_cb_function], :void, blocking: true
479
-
480
- RebalanceCallback = FFI::Function.new(
481
- :void, [:pointer, :int, :pointer, :pointer]
482
- ) do |client_ptr, code, partitions_ptr, opaque_ptr|
483
- case code
484
- when RD_KAFKA_RESP_ERR__ASSIGN_PARTITIONS
485
- if Rdkafka::Bindings.rd_kafka_rebalance_protocol(client_ptr) == "COOPERATIVE"
486
- Rdkafka::Bindings.rd_kafka_incremental_assign(client_ptr, partitions_ptr)
487
- else
488
- Rdkafka::Bindings.rd_kafka_assign(client_ptr, partitions_ptr)
489
- end
490
- else # RD_KAFKA_RESP_ERR__REVOKE_PARTITIONS or errors
491
- if Rdkafka::Bindings.rd_kafka_rebalance_protocol(client_ptr) == "COOPERATIVE"
492
- Rdkafka::Bindings.rd_kafka_incremental_unassign(client_ptr, partitions_ptr)
493
- else
494
- Rdkafka::Bindings.rd_kafka_assign(client_ptr, FFI::Pointer::NULL)
495
- end
496
- end
497
-
498
- opaque = Rdkafka::Config.opaques[opaque_ptr.to_i]
499
- return unless opaque
500
-
501
- tpl = Rdkafka::Consumer::TopicPartitionList.from_native_tpl(partitions_ptr).freeze
502
- begin
503
- case code
504
- when RD_KAFKA_RESP_ERR__ASSIGN_PARTITIONS
505
- opaque.call_on_partitions_assigned(tpl)
506
- when RD_KAFKA_RESP_ERR__REVOKE_PARTITIONS
507
- opaque.call_on_partitions_revoked(tpl)
508
- end
509
- rescue Exception => err
510
- Rdkafka::Config.logger.error("Unhandled exception: #{err.class} - #{err.message}")
511
- end
512
- end
513
-
514
- # Share consumer (KIP-932, preview)
515
- #
516
- # The share consumer is a distinct librdkafka handle type (rd_kafka_share_t) created with
517
- # rd_kafka_share_consumer_new instead of rd_kafka_new. It is single-threaded by design and
518
- # librdkafka itself rejects concurrent access with RD_KAFKA_RESP_ERR__CONFLICT.
519
-
520
- # Minimal mirror of the head of librdkafka's `struct rd_kafka_share_s`, whose first member is
521
- # the wrapped `rd_kafka_t` (`rkshare_rk`). `rd_kafka_share_t` has no public accessors of its
522
- # own - not even for the client name - but the handle it wraps is a normal `rd_kafka_t` and is
523
- # the very handle librdkafka passes to the statistics, error and OAuthBearer callbacks. Reading
524
- # it lets a share consumer report a name that matches its statistics `name` field, which
525
- # `rd_kafka_name` cannot do when handed the `rd_kafka_share_t` directly (it would read an
526
- # unrelated field and return garbage). This mirrors how the gem already maps other librdkafka
527
- # structs by layout for the pinned librdkafka version.
528
- class NativeShareConsumer < FFI::Struct
529
- layout :rkshare_rk, :pointer
530
- end
531
-
532
- # Acknowledge types for share consumer records
533
- RD_KAFKA_SHARE_ACKNOWLEDGE_TYPE_ACCEPT = 1
534
- RD_KAFKA_SHARE_ACKNOWLEDGE_TYPE_RELEASE = 2
535
- RD_KAFKA_SHARE_ACKNOWLEDGE_TYPE_REJECT = 3
536
-
537
- attach_function :rd_kafka_share_consumer_new, [:pointer, :pointer, :size_t], :pointer
538
- attach_function :rd_kafka_share_consumer_close, [:pointer], :pointer, blocking: true
539
- attach_function :rd_kafka_share_consumer_closed, [:pointer], :int
540
- attach_function :rd_kafka_share_destroy, [:pointer], :pointer, blocking: true
541
- attach_function :rd_kafka_share_set_log_queue, [:pointer, :pointer], :pointer
542
-
543
- attach_function :rd_kafka_share_subscribe, [:pointer, :pointer], :int, blocking: true
544
- attach_function :rd_kafka_share_unsubscribe, [:pointer], :int, blocking: true
545
- attach_function :rd_kafka_share_subscription, [:pointer, :pointer], :int, blocking: true
546
-
547
- attach_function :rd_kafka_share_poll, [:pointer, :int, :pointer], :pointer, blocking: true
548
- attach_function :rd_kafka_messages_count, [:pointer], :size_t
549
- attach_function :rd_kafka_messages_get, [:pointer, :size_t], :pointer
550
- attach_function :rd_kafka_messages_destroy, [:pointer], :void
551
- attach_function :rd_kafka_message_delivery_count, [:pointer], :int16
552
-
553
- # The by-coordinates acknowledge variant is the only one we bind: Ruby messages are copies
554
- # that do not retain the native rd_kafka_message_t pointer, so the message-pointer variants
555
- # (rd_kafka_share_acknowledge / rd_kafka_share_acknowledge_type) cannot be used safely here.
556
- attach_function :rd_kafka_share_acknowledge_offset, [:pointer, :string, :int32, :int64, :int], :int
557
-
558
- attach_function :rd_kafka_share_commit_sync, [:pointer, :int, :pointer], :pointer, blocking: true
559
- attach_function :rd_kafka_share_commit_async, [:pointer], :pointer
560
-
561
- callback :share_acknowledgement_commit_cb, [:pointer, :pointer, :int, :pointer], :void
562
- attach_function :rd_kafka_share_set_acknowledgement_commit_cb, [:pointer, :share_acknowledgement_commit_cb, :pointer], :pointer
563
-
564
- # Accessors for the rd_kafka_share_partition_offsets_list_t handed to the acknowledgement
565
- # commit callback. The list is owned by librdkafka for the duration of the callback: read it
566
- # inside the callback only, never destroy or retain it.
567
- attach_function :rd_kafka_share_partition_offsets_list_count, [:pointer], :size_t
568
- attach_function :rd_kafka_share_partition_offsets_list_get, [:pointer, :size_t], :pointer
569
- attach_function :rd_kafka_share_partition_offsets_partition, [:pointer], :pointer
570
- attach_function :rd_kafka_share_partition_offsets_offsets, [:pointer], :pointer
571
- attach_function :rd_kafka_share_partition_offsets_offsets_cnt, [:pointer], :size_t
572
-
573
- attach_function :rd_kafka_share_oauthbearer_set_token, [:pointer, :string, :int64, :string, :pointer, :size_t, :pointer, :size_t], :int
574
- attach_function :rd_kafka_share_oauthbearer_set_token_failure, [:pointer, :string], :int
575
-
576
- # Stats
577
-
578
- attach_function :rd_kafka_query_watermark_offsets, [:pointer, :string, :int, :pointer, :pointer, :int], :int, blocking: true
579
-
580
- # Producer
581
- RD_KAFKA_VTYPE_END = 0
582
- RD_KAFKA_VTYPE_TOPIC = 1
583
- RD_KAFKA_VTYPE_RKT = 2
584
- RD_KAFKA_VTYPE_PARTITION = 3
585
- RD_KAFKA_VTYPE_VALUE = 4
586
- RD_KAFKA_VTYPE_KEY = 5
587
- RD_KAFKA_VTYPE_OPAQUE = 6
588
- RD_KAFKA_VTYPE_MSGFLAGS = 7
589
- RD_KAFKA_VTYPE_TIMESTAMP = 8
590
- RD_KAFKA_VTYPE_HEADER = 9
591
- RD_KAFKA_VTYPE_HEADERS = 10
592
- RD_KAFKA_PURGE_F_QUEUE = 1
593
- RD_KAFKA_PURGE_F_INFLIGHT = 2
594
-
595
- RD_KAFKA_MSG_F_COPY = 0x2
596
-
597
- attach_function :rd_kafka_producev, [:pointer, :varargs], :int, blocking: true
598
- attach_function :rd_kafka_purge, [:pointer, :int], :int, blocking: true
599
- callback :delivery_cb, [:pointer, :pointer, :pointer], :void
600
- attach_function :rd_kafka_conf_set_dr_msg_cb, [:pointer, :delivery_cb], :void
601
- attach_function :rd_kafka_init_transactions, [:pointer, :int], :pointer, blocking: true
602
- attach_function :rd_kafka_send_offsets_to_transaction, [:pointer, :pointer, :pointer, :int], :pointer, blocking: true
603
- attach_function :rd_kafka_begin_transaction, [:pointer], :pointer, blocking: true
604
- attach_function :rd_kafka_abort_transaction, [:pointer, :int], :pointer, blocking: true
605
- attach_function :rd_kafka_commit_transaction, [:pointer, :int], :pointer, blocking: true
606
-
607
- # Hash mapping partitioner names to their FFI function symbols
608
- # @return [Hash{String => Symbol}]
609
- PARTITIONERS = %w[random consistent consistent_random murmur2 murmur2_random fnv1a fnv1a_random].each_with_object({}) do |name, hsh|
610
- method_name = :"rd_kafka_msg_partitioner_#{name}"
611
- attach_function method_name, [:pointer, :pointer, :size_t, :int32, :pointer, :pointer], :int32
612
- hsh[name] = method_name
613
- end
614
-
615
- # Calculates the partition for a message based on the partitioner
616
- #
617
- # @param topic_ptr [FFI::Pointer] pointer to the topic handle
618
- # @param str [String] the partition key string
619
- # @param partition_count [Integer, nil] number of partitions
620
- # @param partitioner [String] name of the partitioner to use
621
- # @return [Integer] partition number or RD_KAFKA_PARTITION_UA if unassigned
622
- # @raise [Rdkafka::Config::ConfigError] when an unknown partitioner is specified
623
- def self.partitioner(topic_ptr, str, partition_count, partitioner = "consistent_random")
624
- # Return RD_KAFKA_PARTITION_UA(unassigned partition) when partition count is nil/zero.
625
- return RD_KAFKA_PARTITION_UA unless partition_count&.nonzero?
626
-
627
- str_ptr = str.empty? ? FFI::MemoryPointer::NULL : FFI::MemoryPointer.from_string(str)
628
- method_name = PARTITIONERS.fetch(partitioner) do
629
- raise Rdkafka::Config::ConfigError.new("Unknown partitioner: #{partitioner}")
630
- end
631
-
632
- public_send(method_name, topic_ptr, str_ptr, partition_key_length(str), partition_count, nil, nil)
633
- end
634
-
635
- # Partition key length as the character count (legacy default).
636
- #
637
- # @param str [String] the partition key string
638
- # @return [Integer]
639
- def self.partition_key_size(str)
640
- str.size
641
- end
642
-
643
- # Partition key length as the byte count, which is what librdkafka hashes (UTF-8 bytes copied
644
- # into the key pointer) and what other Kafka clients use.
645
- #
646
- # @param str [String] the partition key string
647
- # @return [Integer]
648
- def self.partition_key_bytesize(str)
649
- str.bytesize
650
- end
651
-
652
- # Length of the partition key passed to librdkafka. Aliased to one of the methods above by
653
- # `Rdkafka::Config.partitioner_key_uses_bytesize=`, so the per-message path does not check the
654
- # setting on every call.
655
- singleton_class.alias_method :partition_key_length, :partition_key_size
656
-
657
- # Create Topics
658
- RD_KAFKA_ADMIN_OP_CREATETOPICS = 1 # rd_kafka_admin_op_t
659
- RD_KAFKA_EVENT_CREATETOPICS_RESULT = 100 # rd_kafka_event_type_t
660
-
661
- attach_function :rd_kafka_CreateTopics, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
662
- attach_function :rd_kafka_NewTopic_new, [:pointer, :size_t, :size_t, :pointer, :size_t], :pointer, blocking: true
663
- attach_function :rd_kafka_NewTopic_set_config, [:pointer, :string, :string], :int32, blocking: true
664
- attach_function :rd_kafka_NewTopic_destroy, [:pointer], :void, blocking: true
665
- attach_function :rd_kafka_event_CreateTopics_result, [:pointer], :pointer, blocking: true
666
- attach_function :rd_kafka_CreateTopics_result_topics, [:pointer, :pointer], :pointer, blocking: true
667
-
668
- # Delete Topics
669
- RD_KAFKA_ADMIN_OP_DELETETOPICS = 2 # rd_kafka_admin_op_t
670
- RD_KAFKA_EVENT_DELETETOPICS_RESULT = 101 # rd_kafka_event_type_t
671
-
672
- attach_function :rd_kafka_DeleteTopics, [:pointer, :pointer, :size_t, :pointer, :pointer], :int32, blocking: true
673
- attach_function :rd_kafka_DeleteTopic_new, [:pointer], :pointer, blocking: true
674
- attach_function :rd_kafka_DeleteTopic_destroy, [:pointer], :void, blocking: true
675
- attach_function :rd_kafka_event_DeleteTopics_result, [:pointer], :pointer, blocking: true
676
- attach_function :rd_kafka_DeleteTopics_result_topics, [:pointer, :pointer], :pointer, blocking: true
677
-
678
- # Create partitions
679
- RD_KAFKA_ADMIN_OP_CREATEPARTITIONS = 3
680
- RD_KAFKA_ADMIN_OP_CREATEPARTITIONS_RESULT = 102
681
-
682
- attach_function :rd_kafka_CreatePartitions, [:pointer, :pointer, :size_t, :pointer, :pointer], :void
683
- attach_function :rd_kafka_NewPartitions_new, %i[pointer size_t pointer size_t], :pointer
684
- attach_function :rd_kafka_NewPartitions_destroy, [:pointer], :void
685
- attach_function :rd_kafka_event_CreatePartitions_result, [:pointer], :pointer
686
- attach_function :rd_kafka_CreatePartitions_result_topics, [:pointer, :pointer], :pointer
687
-
688
- # Delete Group
689
- RD_KAFKA_ADMIN_OP_DELETEGROUPS = 7 # rd_kafka_admin_op_t
690
- RD_KAFKA_EVENT_DELETEGROUPS_RESULT = 106 # rd_kafka_event_type_t
691
-
692
- attach_function :rd_kafka_DeleteGroups, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
693
- attach_function :rd_kafka_DeleteGroup_new, [:pointer], :pointer, blocking: true
694
- attach_function :rd_kafka_DeleteGroup_destroy, [:pointer], :void, blocking: true
695
- attach_function :rd_kafka_event_DeleteGroups_result, [:pointer], :pointer, blocking: true # rd_kafka_event_t* => rd_kafka_DeleteGroups_result_t*
696
- attach_function :rd_kafka_DeleteGroups_result_groups, [:pointer, :pointer], :pointer, blocking: true # rd_kafka_DeleteGroups_result_t*, size_t* => rd_kafka_group_result_t**
697
-
698
- # Alter Consumer Group Offsets
699
- RD_KAFKA_ADMIN_OP_ALTERCONSUMERGROUPOFFSETS = 15 # rd_kafka_admin_op_t
700
- RD_KAFKA_EVENT_ALTERCONSUMERGROUPOFFSETS_RESULT = 0x10000 # rd_kafka_event_type_t
701
-
702
- attach_function :rd_kafka_AlterConsumerGroupOffsets, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
703
- attach_function :rd_kafka_AlterConsumerGroupOffsets_new, [:pointer, :pointer], :pointer, blocking: true # const char*, const rd_kafka_topic_partition_list_t* => rd_kafka_AlterConsumerGroupOffsets_t*
704
- attach_function :rd_kafka_AlterConsumerGroupOffsets_destroy, [:pointer], :void, blocking: true
705
- attach_function :rd_kafka_event_AlterConsumerGroupOffsets_result, [:pointer], :pointer, blocking: true # rd_kafka_event_t* => rd_kafka_AlterConsumerGroupOffsets_result_t*
706
- attach_function :rd_kafka_AlterConsumerGroupOffsets_result_groups, [:pointer, :pointer], :pointer, blocking: true # rd_kafka_AlterConsumerGroupOffsets_result_t*, size_t* => rd_kafka_group_result_t**
707
-
708
- # Delete Consumer Group Offsets
709
- RD_KAFKA_ADMIN_OP_DELETECONSUMERGROUPOFFSETS = 8 # rd_kafka_admin_op_t
710
- RD_KAFKA_EVENT_DELETECONSUMERGROUPOFFSETS_RESULT = 107 # rd_kafka_event_type_t
711
-
712
- attach_function :rd_kafka_DeleteConsumerGroupOffsets, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
713
- attach_function :rd_kafka_DeleteConsumerGroupOffsets_new, [:pointer, :pointer], :pointer, blocking: true # const char*, const rd_kafka_topic_partition_list_t* => rd_kafka_DeleteConsumerGroupOffsets_t*
714
- attach_function :rd_kafka_DeleteConsumerGroupOffsets_destroy, [:pointer], :void, blocking: true
715
- attach_function :rd_kafka_event_DeleteConsumerGroupOffsets_result, [:pointer], :pointer, blocking: true # rd_kafka_event_t* => rd_kafka_DeleteConsumerGroupOffsets_result_t*
716
- attach_function :rd_kafka_DeleteConsumerGroupOffsets_result_groups, [:pointer, :pointer], :pointer, blocking: true # rd_kafka_DeleteConsumerGroupOffsets_result_t*, size_t* => rd_kafka_group_result_t**
717
-
718
- # Delete Records
719
- RD_KAFKA_ADMIN_OP_DELETERECORDS = 6 # rd_kafka_admin_op_t
720
- RD_KAFKA_EVENT_DELETERECORDS_RESULT = 105 # rd_kafka_event_type_t
721
-
722
- attach_function :rd_kafka_DeleteRecords, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
723
- attach_function :rd_kafka_DeleteRecords_new, [:pointer], :pointer, blocking: true
724
- attach_function :rd_kafka_DeleteRecords_destroy, [:pointer], :void, blocking: true
725
- attach_function :rd_kafka_event_DeleteRecords_result, [:pointer], :pointer, blocking: true # rd_kafka_event_t* => rd_kafka_DeleteRecords_result_t*
726
- attach_function :rd_kafka_DeleteRecords_result_offsets, [:pointer], :pointer, blocking: true # rd_kafka_DeleteRecords_result_t* => rd_kafka_topic_partition_list_t*
727
-
728
- # List Consumer Groups
729
- RD_KAFKA_ADMIN_OP_LISTCONSUMERGROUPS = 12 # rd_kafka_admin_op_t
730
- RD_KAFKA_EVENT_LISTCONSUMERGROUPS_RESULT = 0x2000 # rd_kafka_event_type_t
731
-
732
- # Consumer group states (rd_kafka_consumer_group_state_t)
733
- RD_KAFKA_CONSUMER_GROUP_STATE_UNKNOWN = 0
734
- RD_KAFKA_CONSUMER_GROUP_STATE_PREPARING_REBALANCE = 1
735
- RD_KAFKA_CONSUMER_GROUP_STATE_COMPLETING_REBALANCE = 2
736
- RD_KAFKA_CONSUMER_GROUP_STATE_STABLE = 3
737
- RD_KAFKA_CONSUMER_GROUP_STATE_DEAD = 4
738
- RD_KAFKA_CONSUMER_GROUP_STATE_EMPTY = 5
739
-
740
- attach_function :rd_kafka_ListConsumerGroups, [:pointer, :pointer, :pointer], :void, blocking: true
741
- attach_function :rd_kafka_event_ListConsumerGroups_result, [:pointer], :pointer, blocking: true # rd_kafka_event_t* => rd_kafka_ListConsumerGroups_result_t*
742
- attach_function :rd_kafka_ListConsumerGroups_result_valid, [:pointer, :pointer], :pointer, blocking: true # result*, size_t* => rd_kafka_ConsumerGroupListing_t**
743
- attach_function :rd_kafka_ListConsumerGroups_result_errors, [:pointer, :pointer], :pointer, blocking: true # result*, size_t* => rd_kafka_error_t**
744
- attach_function :rd_kafka_ConsumerGroupListing_group_id, [:pointer], :pointer, blocking: true # => const char*
745
- attach_function :rd_kafka_ConsumerGroupListing_is_simple_consumer_group, [:pointer], :int, blocking: true
746
- attach_function :rd_kafka_ConsumerGroupListing_state, [:pointer], :int, blocking: true
747
- attach_function :rd_kafka_consumer_group_state_name, [:int], :pointer, blocking: true # => const char*
748
-
749
- # Background Queue and Callback
750
-
751
- attach_function :rd_kafka_conf_set_background_event_cb, [:pointer, :pointer], :void
752
- attach_function :rd_kafka_queue_destroy, [:pointer], :void
753
-
754
- # Admin Options
755
-
756
- attach_function :rd_kafka_AdminOptions_new, [:pointer, :int32], :pointer
757
- attach_function :rd_kafka_AdminOptions_set_opaque, [:pointer, :pointer], :void
758
- attach_function :rd_kafka_AdminOptions_destroy, [:pointer], :void
759
-
760
- # Extracting data from event types
761
-
762
- attach_function :rd_kafka_event_type, [:pointer], :int32
763
- attach_function :rd_kafka_event_opaque, [:pointer], :pointer
764
- attach_function :rd_kafka_event_destroy, [:pointer], :void
765
-
766
- # Extracting data from topic results
767
-
768
- attach_function :rd_kafka_topic_result_error, [:pointer], :int32
769
- attach_function :rd_kafka_topic_result_error_string, [:pointer], :pointer
770
- attach_function :rd_kafka_topic_result_name, [:pointer], :pointer
771
-
772
- # Create Acls
773
- RD_KAFKA_ADMIN_OP_CREATEACLS = 9
774
- RD_KAFKA_EVENT_CREATEACLS_RESULT = 1024
775
-
776
- attach_function :rd_kafka_CreateAcls, [:pointer, :pointer, :size_t, :pointer, :pointer], :void
777
- attach_function :rd_kafka_event_CreateAcls_result, [:pointer], :pointer
778
- attach_function :rd_kafka_CreateAcls_result_acls, [:pointer, :pointer], :pointer
779
-
780
- # Delete Acls
781
- RD_KAFKA_ADMIN_OP_DELETEACLS = 11
782
- RD_KAFKA_EVENT_DELETEACLS_RESULT = 4096
783
-
784
- attach_function :rd_kafka_DeleteAcls, [:pointer, :pointer, :size_t, :pointer, :pointer], :void
785
- attach_function :rd_kafka_event_DeleteAcls_result, [:pointer], :pointer
786
- attach_function :rd_kafka_DeleteAcls_result_responses, [:pointer, :pointer], :pointer
787
- attach_function :rd_kafka_DeleteAcls_result_response_error, [:pointer], :pointer
788
- attach_function :rd_kafka_DeleteAcls_result_response_matching_acls, [:pointer, :pointer], :pointer
789
-
790
- # Describe Acls
791
- RD_KAFKA_ADMIN_OP_DESCRIBEACLS = 10
792
- RD_KAFKA_EVENT_DESCRIBEACLS_RESULT = 2048
793
-
794
- attach_function :rd_kafka_DescribeAcls, [:pointer, :pointer, :pointer, :pointer], :void
795
- attach_function :rd_kafka_event_DescribeAcls_result, [:pointer], :pointer
796
- attach_function :rd_kafka_DescribeAcls_result_acls, [:pointer, :pointer], :pointer
797
-
798
- # Acl Bindings
799
-
800
- attach_function :rd_kafka_AclBinding_restype, [:pointer], :int32
801
- attach_function :rd_kafka_AclBinding_name, [:pointer], :pointer
802
- attach_function :rd_kafka_AclBinding_resource_pattern_type, [:pointer], :int32
803
- attach_function :rd_kafka_AclBinding_principal, [:pointer], :pointer
804
- attach_function :rd_kafka_AclBinding_host, [:pointer], :pointer
805
- attach_function :rd_kafka_AclBinding_operation, [:pointer], :int32
806
- attach_function :rd_kafka_AclBinding_permission_type, [:pointer], :int32
807
- attach_function :rd_kafka_AclBinding_new, [:int32, :pointer, :int32, :pointer, :pointer, :int32, :int32, :pointer, :size_t], :pointer
808
- attach_function :rd_kafka_AclBindingFilter_new, [:int32, :pointer, :int32, :pointer, :pointer, :int32, :int32, :pointer, :size_t], :pointer
809
- attach_function :rd_kafka_AclBinding_destroy, [:pointer], :void
810
-
811
- # rd_kafka_ResourceType_t -
812
- # https://github.com/confluentinc/librdkafka/blob/292d2a66b992/src/rdkafka.h#L7307
813
- RD_KAFKA_RESOURCE_ANY = 1
814
- RD_KAFKA_RESOURCE_TOPIC = 2
815
- RD_KAFKA_RESOURCE_GROUP = 3
816
- RD_KAFKA_RESOURCE_BROKER = 4
817
- RD_KAFKA_RESOURCE_TRANSACTIONAL_ID = 5
818
-
819
- # rd_kafka_ResourcePatternType_t -
820
- # https://github.com/confluentinc/librdkafka/blob/292d2a66b992/src/rdkafka.h#L7320
821
- RD_KAFKA_RESOURCE_PATTERN_UNKNOWN = 0
822
- RD_KAFKA_RESOURCE_PATTERN_ANY = 1
823
- RD_KAFKA_RESOURCE_PATTERN_MATCH = 2
824
- RD_KAFKA_RESOURCE_PATTERN_LITERAL = 3
825
- RD_KAFKA_RESOURCE_PATTERN_PREFIXED = 4
826
-
827
- # rd_kafka_AclOperation_t -
828
- # https://github.com/confluentinc/librdkafka/blob/292d2a66b992/src/rdkafka.h#L8403
829
- RD_KAFKA_ACL_OPERATION_ANY = 1
830
- RD_KAFKA_ACL_OPERATION_ALL = 2
831
- RD_KAFKA_ACL_OPERATION_READ = 3
832
- RD_KAFKA_ACL_OPERATION_WRITE = 4
833
- RD_KAFKA_ACL_OPERATION_CREATE = 5
834
- RD_KAFKA_ACL_OPERATION_DELETE = 6
835
- RD_KAFKA_ACL_OPERATION_ALTER = 7
836
- RD_KAFKA_ACL_OPERATION_DESCRIBE = 8
837
- RD_KAFKA_ACL_OPERATION_CLUSTER_ACTION = 9
838
- RD_KAFKA_ACL_OPERATION_DESCRIBE_CONFIGS = 10
839
- RD_KAFKA_ACL_OPERATION_ALTER_CONFIGS = 11
840
- RD_KAFKA_ACL_OPERATION_IDEMPOTENT_WRITE = 12
841
-
842
- # rd_kafka_AclPermissionType_t -
843
- # https://github.com/confluentinc/librdkafka/blob/292d2a66b992/src/rdkafka.h#L8435
844
- RD_KAFKA_ACL_PERMISSION_TYPE_ANY = 1
845
- RD_KAFKA_ACL_PERMISSION_TYPE_DENY = 2
846
- RD_KAFKA_ACL_PERMISSION_TYPE_ALLOW = 3
847
-
848
- # Extracting error details from Acl results
849
- attach_function :rd_kafka_acl_result_error, [:pointer], :pointer
850
- attach_function :rd_kafka_error_code, [:pointer], :int32
851
- attach_function :rd_kafka_error_string, [:pointer], :pointer
852
- attach_function :rd_kafka_event_error, [:pointer], :int32
853
- attach_function :rd_kafka_event_error_string, [:pointer], :pointer
854
- attach_function :rd_kafka_AclBinding_error, [:pointer], :pointer
855
-
856
- # FFI struct for native error (rd_kafka_error_t)
857
- class NativeError < FFI::Struct
858
- layout :code, :int32,
859
- :errstr, :pointer,
860
- :fatal, :u_int8_t,
861
- :retriable, :u_int8_t,
862
- :txn_requires_abort, :u_int8_t
863
- end
864
-
865
- attach_function :rd_kafka_group_result_error, [:pointer], NativeError.by_ref # rd_kafka_group_result_t* => rd_kafka_error_t*
866
- attach_function :rd_kafka_group_result_name, [:pointer], :pointer
867
- attach_function :rd_kafka_group_result_partitions, [:pointer], :pointer # rd_kafka_group_result_t* => rd_kafka_topic_partition_list_t*
868
93
  end
869
94
  end
95
+
96
+ require_relative "bindings/structs"
97
+ require_relative "bindings/polling"
98
+ require_relative "bindings/metadata"
99
+ require_relative "bindings/messages"
100
+ require_relative "bindings/errors"
101
+ require_relative "bindings/configuration"
102
+ require_relative "bindings/callbacks"
103
+ require_relative "bindings/handle"
104
+ require_relative "bindings/consumer"
105
+ require_relative "bindings/share_consumer"
106
+ require_relative "bindings/producer"
107
+ require_relative "bindings/admin"