|
2 | 2 |
|
3 | 3 | module Rdkafka
|
4 | 4 | # @private
|
| 5 | + # |
| 6 | + # @note |
| 7 | + # There are two types of responses related to errors: |
| 8 | + # - rd_kafka_error_t - a C object that we need to remap into an error or null when no error |
| 9 | + # - rd_kafka_resp_err_t - response error code (numeric) that we can use directly |
| 10 | + # |
| 11 | + # It is critical to ensure, that we handle them correctly. The result type should be: |
| 12 | + # - rd_kafka_error_t - :pointer |
| 13 | + # - rd_kafka_resp_err_t - :int |
5 | 14 | module Bindings
|
6 | 15 | extend FFI::Library
|
7 | 16 |
|
@@ -38,7 +47,7 @@ class SizePtr < FFI::Struct
|
38 | 47 |
|
39 | 48 | # Metadata
|
40 | 49 |
|
41 |
| - attach_function :rd_kafka_name, [:pointer], :string, blocking: true |
| 50 | + attach_function :rd_kafka_name, [:pointer], :string |
42 | 51 | attach_function :rd_kafka_memberid, [:pointer], :string, blocking: true
|
43 | 52 | attach_function :rd_kafka_clusterid, [:pointer], :string, blocking: true
|
44 | 53 | attach_function :rd_kafka_metadata, [:pointer, :int, :pointer, :pointer, :int], :int, blocking: true
|
@@ -84,7 +93,7 @@ class TopicPartitionList < FFI::Struct
|
84 | 93 | end
|
85 | 94 |
|
86 | 95 | attach_function :rd_kafka_topic_partition_list_new, [:int32], :pointer
|
87 |
| - attach_function :rd_kafka_topic_partition_list_add, [:pointer, :string, :int32], :void |
| 96 | + attach_function :rd_kafka_topic_partition_list_add, [:pointer, :string, :int32], :pointer |
88 | 97 | attach_function :rd_kafka_topic_partition_list_set_offset, [:pointer, :string, :int32, :int64], :void
|
89 | 98 | attach_function :rd_kafka_topic_partition_list_destroy, [:pointer], :void
|
90 | 99 | attach_function :rd_kafka_topic_partition_list_copy, [:pointer], :pointer
|
@@ -140,6 +149,11 @@ class NativeErrorDesc < FFI::Struct
|
140 | 149 |
|
141 | 150 | attach_function :rd_kafka_err2name, [:int], :string
|
142 | 151 | attach_function :rd_kafka_err2str, [:int], :string
|
| 152 | + attach_function :rd_kafka_error_is_fatal, [:pointer], :int |
| 153 | + attach_function :rd_kafka_error_is_retriable, [:pointer], :int |
| 154 | + attach_function :rd_kafka_error_txn_requires_abort, [:pointer], :int |
| 155 | + attach_function :rd_kafka_error_destroy, [:pointer], :void |
| 156 | + attach_function :rd_kafka_error_code, [:pointer], :int |
143 | 157 | attach_function :rd_kafka_get_err_descs, [:pointer, :pointer], :void
|
144 | 158 |
|
145 | 159 | # Configuration
|
@@ -210,7 +224,7 @@ class NativeErrorDesc < FFI::Struct
|
210 | 224 | :void, [:pointer, :int, :string, :pointer]
|
211 | 225 | ) do |_client_prr, err_code, reason, _opaque|
|
212 | 226 | if Rdkafka::Config.error_callback
|
213 |
| - error = Rdkafka::RdkafkaError.new(err_code, broker_message: reason) |
| 227 | + error = Rdkafka::RdkafkaError.build(err_code, broker_message: reason) |
214 | 228 | error.set_backtrace(caller)
|
215 | 229 | Rdkafka::Config.error_callback.call(error)
|
216 | 230 | end
|
@@ -347,6 +361,11 @@ class NativeErrorDesc < FFI::Struct
|
347 | 361 | attach_function :rd_kafka_purge, [:pointer, :int], :int, blocking: true
|
348 | 362 | callback :delivery_cb, [:pointer, :pointer, :pointer], :void
|
349 | 363 | attach_function :rd_kafka_conf_set_dr_msg_cb, [:pointer, :delivery_cb], :void
|
| 364 | + attach_function :rd_kafka_init_transactions, [:pointer, :int], :pointer, blocking: true |
| 365 | + attach_function :rd_kafka_send_offsets_to_transaction, [:pointer, :pointer, :pointer, :int], :pointer, blocking: true |
| 366 | + attach_function :rd_kafka_begin_transaction, [:pointer], :pointer, blocking: true |
| 367 | + attach_function :rd_kafka_abort_transaction, [:pointer, :int], :pointer, blocking: true |
| 368 | + attach_function :rd_kafka_commit_transaction, [:pointer, :int], :pointer, blocking: true |
350 | 369 |
|
351 | 370 | # Partitioner
|
352 | 371 | PARTITIONERS = %w(random consistent consistent_random murmur2 murmur2_random fnv1a fnv1a_random).each_with_object({}) do |name, hsh|
|
|
0 commit comments