rdkafka 0.29.2 → 0.31.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +42 -15
- data/README.md +2 -0
- data/dist/librdkafka-2.15.1.tar.gz +0 -0
- data/docker-compose-ssl.yml +1 -0
- data/docker-compose.yml +1 -0
- data/lib/rdkafka/admin/alter_consumer_group_offsets_handle.rb +31 -0
- data/lib/rdkafka/admin/alter_consumer_group_offsets_report.rb +50 -0
- data/lib/rdkafka/admin/delete_consumer_group_offsets_handle.rb +31 -0
- data/lib/rdkafka/admin/delete_consumer_group_offsets_report.rb +50 -0
- data/lib/rdkafka/admin/describe_cluster_handle.rb +31 -0
- data/lib/rdkafka/admin/describe_cluster_report.rb +48 -0
- data/lib/rdkafka/admin/describe_consumer_groups_handle.rb +31 -0
- data/lib/rdkafka/admin/describe_consumer_groups_report.rb +151 -0
- data/lib/rdkafka/admin/describe_result_parsing.rb +47 -0
- data/lib/rdkafka/admin/describe_topics_handle.rb +31 -0
- data/lib/rdkafka/admin/describe_topics_report.rb +118 -0
- data/lib/rdkafka/admin.rb +365 -0
- data/lib/rdkafka/bindings/admin/acls.rb +85 -0
- data/lib/rdkafka/bindings/admin/configs.rb +37 -0
- data/lib/rdkafka/bindings/admin/list_offsets.rb +26 -0
- data/lib/rdkafka/bindings/admin.rb +197 -0
- data/lib/rdkafka/bindings/callbacks.rb +100 -0
- data/lib/rdkafka/bindings/configuration.rb +50 -0
- data/lib/rdkafka/bindings/consumer.rb +83 -0
- data/lib/rdkafka/bindings/errors.rb +15 -0
- data/lib/rdkafka/bindings/handle.rb +16 -0
- data/lib/rdkafka/bindings/messages.rb +28 -0
- data/lib/rdkafka/bindings/metadata.rb +14 -0
- data/lib/rdkafka/bindings/polling.rb +17 -0
- data/lib/rdkafka/bindings/producer.rb +77 -0
- data/lib/rdkafka/bindings/structs.rb +62 -0
- data/lib/rdkafka/bindings.rb +12 -612
- data/lib/rdkafka/callbacks/alter_consumer_group_offsets_handler.rb +65 -0
- data/lib/rdkafka/callbacks/delete_consumer_group_offsets_handler.rb +65 -0
- data/lib/rdkafka/callbacks/describe_cluster_handler.rb +36 -0
- data/lib/rdkafka/callbacks/describe_consumer_groups_handler.rb +36 -0
- data/lib/rdkafka/callbacks/describe_topics_handler.rb +36 -0
- data/lib/rdkafka/callbacks.rb +24 -17
- data/lib/rdkafka/clients.rb +13 -46
- data/lib/rdkafka/config.rb +34 -0
- data/lib/rdkafka/consumer/message.rb +6 -9
- data/lib/rdkafka/producer/delivery_handle.rb +8 -2
- data/lib/rdkafka/producer/delivery_report.rb +51 -1
- data/lib/rdkafka/version.rb +3 -3
- data/lib/rdkafka.rb +16 -0
- data/package-lock.json +9 -9
- data/rdkafka.gemspec +1 -1
- data/renovate.json +3 -0
- metadata +34 -4
- data/dist/librdkafka-2.14.2.tar.gz +0 -0
data/lib/rdkafka/bindings.rb
CHANGED
|
@@ -84,617 +84,17 @@ module Rdkafka
|
|
|
84
84
|
# librdkafka components without initializing the client
|
|
85
85
|
# See: https://github.com/confluentinc/librdkafka/issues/4590
|
|
86
86
|
attach_function :rd_kafka_global_init, [], :void
|
|
87
|
-
|
|
88
|
-
# Polling
|
|
89
|
-
|
|
90
|
-
attach_function :rd_kafka_flush, [:pointer, :int], :int, blocking: true
|
|
91
|
-
attach_function :rd_kafka_poll, [:pointer, :int], :int, blocking: true
|
|
92
|
-
attach_function :rd_kafka_outq_len, [:pointer], :int, blocking: true
|
|
93
|
-
|
|
94
|
-
# Non-blocking poll variants (do not release GVL)
|
|
95
|
-
# These are more efficient for poll(0) calls in fiber schedulers where GVL
|
|
96
|
-
# release/reacquire overhead is wasteful since we don't expect to wait.
|
|
97
|
-
# Uses the same underlying C function but with blocking: false to skip GVL release.
|
|
98
|
-
attach_function :rd_kafka_poll_nb, :rd_kafka_poll, [:pointer, :int], :int, blocking: false
|
|
99
|
-
|
|
100
|
-
# Metadata
|
|
101
|
-
|
|
102
|
-
attach_function :rd_kafka_name, [:pointer], :string
|
|
103
|
-
attach_function :rd_kafka_memberid, [:pointer], :pointer, blocking: true
|
|
104
|
-
attach_function :rd_kafka_clusterid, [:pointer, :int], :pointer, blocking: true
|
|
105
|
-
attach_function :rd_kafka_mem_free, [:pointer, :pointer], :void
|
|
106
|
-
attach_function :rd_kafka_metadata, [:pointer, :int, :pointer, :pointer, :int], :int, blocking: true
|
|
107
|
-
attach_function :rd_kafka_metadata_destroy, [:pointer], :void, blocking: true
|
|
108
|
-
|
|
109
|
-
# FFI struct representing a Kafka message (rd_kafka_message_t)
|
|
110
|
-
class Message < FFI::Struct
|
|
111
|
-
layout :err, :int,
|
|
112
|
-
:rkt, :pointer,
|
|
113
|
-
:partition, :int32,
|
|
114
|
-
:payload, :pointer,
|
|
115
|
-
:len, :size_t,
|
|
116
|
-
:key, :pointer,
|
|
117
|
-
:key_len, :size_t,
|
|
118
|
-
:offset, :int64,
|
|
119
|
-
:_private, :pointer
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
attach_function :rd_kafka_message_destroy, [:pointer], :void
|
|
123
|
-
attach_function :rd_kafka_message_timestamp, [:pointer, :pointer], :int64
|
|
124
|
-
attach_function :rd_kafka_topic_new, [:pointer, :string, :pointer], :pointer
|
|
125
|
-
attach_function :rd_kafka_topic_destroy, [:pointer], :pointer
|
|
126
|
-
attach_function :rd_kafka_topic_name, [:pointer], :string
|
|
127
|
-
|
|
128
|
-
# FFI struct representing a topic partition (rd_kafka_topic_partition_t)
|
|
129
|
-
class TopicPartition < FFI::Struct
|
|
130
|
-
layout :topic, :string,
|
|
131
|
-
:partition, :int32,
|
|
132
|
-
:offset, :int64,
|
|
133
|
-
:metadata, :pointer,
|
|
134
|
-
:metadata_size, :size_t,
|
|
135
|
-
:opaque, :pointer,
|
|
136
|
-
:err, :int,
|
|
137
|
-
:_private, :pointer
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
# FFI struct representing a topic partition list (rd_kafka_topic_partition_list_t)
|
|
141
|
-
class TopicPartitionList < FFI::Struct
|
|
142
|
-
layout :cnt, :int,
|
|
143
|
-
:size, :int,
|
|
144
|
-
:elems, :pointer
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
attach_function :rd_kafka_topic_partition_list_new, [:int32], :pointer
|
|
148
|
-
attach_function :rd_kafka_topic_partition_list_add, [:pointer, :string, :int32], :pointer
|
|
149
|
-
attach_function :rd_kafka_topic_partition_list_set_offset, [:pointer, :string, :int32, :int64], :void
|
|
150
|
-
attach_function :rd_kafka_topic_partition_list_destroy, [:pointer], :void
|
|
151
|
-
attach_function :rd_kafka_topic_partition_list_copy, [:pointer], :pointer
|
|
152
|
-
|
|
153
|
-
# FFI struct representing a config resource (rd_kafka_ConfigResource_t)
|
|
154
|
-
# Structs for management of configurations. Each configuration is attached to a resource
|
|
155
|
-
# and one resource can have many configuration details. Each resource will also have
|
|
156
|
-
# separate errors results if obtaining configuration was not possible for any reason
|
|
157
|
-
class ConfigResource < FFI::Struct
|
|
158
|
-
layout :type, :int,
|
|
159
|
-
:name, :string
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
attach_function :rd_kafka_DescribeConfigs, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
|
|
163
|
-
attach_function :rd_kafka_ConfigResource_new, [:int32, :pointer], :pointer
|
|
164
|
-
attach_function :rd_kafka_ConfigResource_destroy, [:pointer], :void
|
|
165
|
-
attach_function :rd_kafka_ConfigResource_destroy_array, [:pointer, :int32], :void
|
|
166
|
-
attach_function :rd_kafka_event_DescribeConfigs_result, [:pointer], :pointer
|
|
167
|
-
attach_function :rd_kafka_DescribeConfigs_result_resources, [:pointer, :pointer], :pointer
|
|
168
|
-
attach_function :rd_kafka_ConfigResource_configs, [:pointer, :pointer], :pointer
|
|
169
|
-
attach_function :rd_kafka_ConfigEntry_name, [:pointer], :string
|
|
170
|
-
attach_function :rd_kafka_ConfigEntry_value, [:pointer], :string
|
|
171
|
-
attach_function :rd_kafka_ConfigEntry_is_read_only, [:pointer], :int
|
|
172
|
-
attach_function :rd_kafka_ConfigEntry_is_default, [:pointer], :int
|
|
173
|
-
attach_function :rd_kafka_ConfigEntry_is_sensitive, [:pointer], :int
|
|
174
|
-
attach_function :rd_kafka_ConfigEntry_is_synonym, [:pointer], :int
|
|
175
|
-
attach_function :rd_kafka_ConfigEntry_synonyms, [:pointer, :pointer], :pointer
|
|
176
|
-
attach_function :rd_kafka_ConfigResource_error, [:pointer], :int
|
|
177
|
-
attach_function :rd_kafka_ConfigResource_error_string, [:pointer], :string
|
|
178
|
-
attach_function :rd_kafka_IncrementalAlterConfigs, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
|
|
179
|
-
attach_function :rd_kafka_IncrementalAlterConfigs_result_resources, [:pointer, :pointer], :pointer
|
|
180
|
-
attach_function :rd_kafka_ConfigResource_add_incremental_config, [:pointer, :string, :int32, :string], :pointer
|
|
181
|
-
attach_function :rd_kafka_event_IncrementalAlterConfigs_result, [:pointer], :pointer
|
|
182
|
-
|
|
183
|
-
RD_KAFKA_ADMIN_OP_DESCRIBECONFIGS = 5
|
|
184
|
-
RD_KAFKA_EVENT_DESCRIBECONFIGS_RESULT = 104
|
|
185
|
-
|
|
186
|
-
RD_KAFKA_ADMIN_OP_INCREMENTALALTERCONFIGS = 16
|
|
187
|
-
RD_KAFKA_EVENT_INCREMENTALALTERCONFIGS_RESULT = 131072
|
|
188
|
-
|
|
189
|
-
RD_KAFKA_ALTER_CONFIG_OP_TYPE_SET = 0
|
|
190
|
-
RD_KAFKA_ALTER_CONFIG_OP_TYPE_DELETE = 1
|
|
191
|
-
RD_KAFKA_ALTER_CONFIG_OP_TYPE_APPEND = 2
|
|
192
|
-
RD_KAFKA_ALTER_CONFIG_OP_TYPE_SUBTRACT = 3
|
|
193
|
-
|
|
194
|
-
# List Offsets
|
|
195
|
-
RD_KAFKA_ADMIN_OP_LISTOFFSETS = 20
|
|
196
|
-
RD_KAFKA_EVENT_LISTOFFSETS_RESULT = 0x400000
|
|
197
|
-
|
|
198
|
-
# rd_kafka_IsolationLevel_t
|
|
199
|
-
RD_KAFKA_ISOLATION_LEVEL_READ_UNCOMMITTED = 0
|
|
200
|
-
RD_KAFKA_ISOLATION_LEVEL_READ_COMMITTED = 1
|
|
201
|
-
|
|
202
|
-
# rd_kafka_OffsetSpec_t
|
|
203
|
-
RD_KAFKA_OFFSET_SPEC_MAX_TIMESTAMP = -3
|
|
204
|
-
RD_KAFKA_OFFSET_SPEC_EARLIEST = -2
|
|
205
|
-
RD_KAFKA_OFFSET_SPEC_LATEST = -1
|
|
206
|
-
|
|
207
|
-
attach_function :rd_kafka_ListOffsets, [:pointer, :pointer, :pointer, :pointer], :void, blocking: true
|
|
208
|
-
attach_function :rd_kafka_event_ListOffsets_result, [:pointer], :pointer
|
|
209
|
-
attach_function :rd_kafka_ListOffsets_result_infos, [:pointer, :pointer], :pointer
|
|
210
|
-
attach_function :rd_kafka_ListOffsetsResultInfo_topic_partition, [:pointer], :pointer
|
|
211
|
-
attach_function :rd_kafka_ListOffsetsResultInfo_timestamp, [:pointer], :int64
|
|
212
|
-
attach_function :rd_kafka_AdminOptions_set_isolation_level, [:pointer, :int], :pointer
|
|
213
|
-
attach_function :rd_kafka_topic_partition_get_leader_epoch, [:pointer], :int32
|
|
214
|
-
|
|
215
|
-
# FFI struct for error description (rd_kafka_err_desc)
|
|
216
|
-
class NativeErrorDesc < FFI::Struct
|
|
217
|
-
layout :code, :int,
|
|
218
|
-
:name, :pointer,
|
|
219
|
-
:desc, :pointer
|
|
220
|
-
end
|
|
221
|
-
|
|
222
|
-
attach_function :rd_kafka_err2name, [:int], :string
|
|
223
|
-
attach_function :rd_kafka_err2str, [:int], :string
|
|
224
|
-
attach_function :rd_kafka_error_is_fatal, [:pointer], :int
|
|
225
|
-
attach_function :rd_kafka_error_is_retriable, [:pointer], :int
|
|
226
|
-
attach_function :rd_kafka_error_txn_requires_abort, [:pointer], :int
|
|
227
|
-
attach_function :rd_kafka_error_destroy, [:pointer], :void
|
|
228
|
-
attach_function :rd_kafka_get_err_descs, [:pointer, :pointer], :void
|
|
229
|
-
|
|
230
|
-
# Configuration
|
|
231
|
-
|
|
232
|
-
enum :kafka_config_response, [
|
|
233
|
-
:config_unknown, -2,
|
|
234
|
-
:config_invalid, -1,
|
|
235
|
-
:config_ok, 0
|
|
236
|
-
]
|
|
237
|
-
|
|
238
|
-
attach_function :rd_kafka_conf_new, [], :pointer
|
|
239
|
-
attach_function :rd_kafka_conf_set, [:pointer, :string, :string, :pointer, :int], :kafka_config_response
|
|
240
|
-
attach_function :rd_kafka_conf_get, [:pointer, :string, :pointer, :pointer], :kafka_config_response
|
|
241
|
-
attach_function :rd_kafka_conf, [:pointer], :pointer
|
|
242
|
-
attach_function :rd_kafka_conf_dump, [:pointer, :pointer], :pointer
|
|
243
|
-
attach_function :rd_kafka_conf_dump_free, [:pointer, :size_t], :void
|
|
244
|
-
attach_function :rd_kafka_conf_destroy, [:pointer], :void
|
|
245
|
-
callback :log_cb, [:pointer, :int, :string, :string], :void
|
|
246
|
-
attach_function :rd_kafka_conf_set_log_cb, [:pointer, :log_cb], :void
|
|
247
|
-
attach_function :rd_kafka_conf_set_opaque, [:pointer, :pointer], :void
|
|
248
|
-
callback :stats_cb, [:pointer, :string, :int, :pointer], :int
|
|
249
|
-
attach_function :rd_kafka_conf_set_stats_cb, [:pointer, :stats_cb], :void
|
|
250
|
-
callback :error_cb, [:pointer, :int, :string, :pointer], :void
|
|
251
|
-
attach_function :rd_kafka_conf_set_error_cb, [:pointer, :error_cb], :void
|
|
252
|
-
attach_function :rd_kafka_rebalance_protocol, [:pointer], :string
|
|
253
|
-
callback :oauthbearer_token_refresh_cb, [:pointer, :string, :pointer], :void
|
|
254
|
-
attach_function :rd_kafka_conf_set_oauthbearer_token_refresh_cb, [:pointer, :oauthbearer_token_refresh_cb], :void
|
|
255
|
-
attach_function :rd_kafka_oauthbearer_set_token, [:pointer, :string, :int64, :pointer, :pointer, :int, :pointer, :int], :int
|
|
256
|
-
attach_function :rd_kafka_oauthbearer_set_token_failure, [:pointer, :string], :int
|
|
257
|
-
# Log queue
|
|
258
|
-
attach_function :rd_kafka_set_log_queue, [:pointer, :pointer], :void
|
|
259
|
-
attach_function :rd_kafka_queue_get_main, [:pointer], :pointer
|
|
260
|
-
attach_function :rd_kafka_queue_get_background, [:pointer], :pointer
|
|
261
|
-
|
|
262
|
-
# Queue IO Event Support - for fiber scheduler integration
|
|
263
|
-
# Enables notifications to a custom FD when queue transitions from empty to non-empty
|
|
264
|
-
# Arguments:
|
|
265
|
-
# - queue (rd_kafka_queue_t*) - the queue to monitor
|
|
266
|
-
# - fd (int) - file descriptor to write to (provide your own pipe/eventfd)
|
|
267
|
-
# - payload (const void*) - data to write to fd
|
|
268
|
-
# - size (size_t) - size of payload
|
|
269
|
-
attach_function :rd_kafka_queue_io_event_enable, [:pointer, :int, :pointer, :size_t], :void
|
|
270
|
-
# Per topic configs
|
|
271
|
-
attach_function :rd_kafka_topic_conf_new, [], :pointer
|
|
272
|
-
attach_function :rd_kafka_topic_conf_destroy, [:pointer], :void
|
|
273
|
-
attach_function :rd_kafka_topic_conf_set, [:pointer, :string, :string, :pointer, :int], :kafka_config_response
|
|
274
|
-
|
|
275
|
-
LogCallback = FFI::Function.new(
|
|
276
|
-
:void, [:pointer, :int, :string, :string]
|
|
277
|
-
) do |_client_ptr, level, _level_string, line|
|
|
278
|
-
severity = case level
|
|
279
|
-
when 0, 1, 2
|
|
280
|
-
Logger::FATAL
|
|
281
|
-
when 3
|
|
282
|
-
Logger::ERROR
|
|
283
|
-
when 4
|
|
284
|
-
Logger::WARN
|
|
285
|
-
when 5, 6
|
|
286
|
-
Logger::INFO
|
|
287
|
-
when 7
|
|
288
|
-
Logger::DEBUG
|
|
289
|
-
else
|
|
290
|
-
Logger::UNKNOWN
|
|
291
|
-
end
|
|
292
|
-
|
|
293
|
-
Rdkafka::Config.ensure_log_thread
|
|
294
|
-
Rdkafka::Config.log_queue << [severity, "rdkafka: #{line}"]
|
|
295
|
-
end
|
|
296
|
-
|
|
297
|
-
StatsCallback = FFI::Function.new(
|
|
298
|
-
:int, [:pointer, :string, :int, :pointer]
|
|
299
|
-
) do |_client_ptr, json, _json_len, _opaque|
|
|
300
|
-
if Rdkafka::Config.statistics_callback
|
|
301
|
-
stats = JSON.parse(json)
|
|
302
|
-
|
|
303
|
-
# If user requested statistics callbacks, we can use the statistics data to get the
|
|
304
|
-
# partitions count for each topic when this data is published. That way we do not have
|
|
305
|
-
# to query this information when user is using `partition_key`. This takes around 0.02ms
|
|
306
|
-
# every statistics interval period (most likely every 5 seconds) and saves us from making
|
|
307
|
-
# any queries to the cluster for the partition count.
|
|
308
|
-
#
|
|
309
|
-
# One edge case is if user would set the `statistics.interval.ms` much higher than the
|
|
310
|
-
# default current partition count refresh (30 seconds). This is taken care of as the lack
|
|
311
|
-
# of reporting to the partitions cache will cause cache expire and blocking refresh.
|
|
312
|
-
#
|
|
313
|
-
# If user sets `topic.metadata.refresh.interval.ms` too high this is on the user.
|
|
314
|
-
#
|
|
315
|
-
# Since this cache is shared, having few consumers and/or producers in one process will
|
|
316
|
-
# automatically improve the querying times even with low refresh times.
|
|
317
|
-
(stats["topics"] || EMPTY_HASH).each do |topic_name, details|
|
|
318
|
-
partitions_count = details["partitions"].keys.count { |k| !(k == RD_KAFKA_PARTITION_UA_STR) }
|
|
319
|
-
|
|
320
|
-
next unless partitions_count.positive?
|
|
321
|
-
|
|
322
|
-
Rdkafka::Producer.partitions_count_cache.set(topic_name, partitions_count)
|
|
323
|
-
end
|
|
324
|
-
|
|
325
|
-
Rdkafka::Config.statistics_callback.call(stats)
|
|
326
|
-
end
|
|
327
|
-
|
|
328
|
-
# Return 0 so librdkafka frees the json string
|
|
329
|
-
RD_KAFKA_RESP_ERR_NO_ERROR
|
|
330
|
-
end
|
|
331
|
-
|
|
332
|
-
ErrorCallback = FFI::Function.new(
|
|
333
|
-
:void, [:pointer, :int, :string, :pointer]
|
|
334
|
-
) do |client_ptr, err_code, reason, _opaque|
|
|
335
|
-
if Rdkafka::Config.error_callback
|
|
336
|
-
instance_name = client_ptr.null? ? nil : Rdkafka::Bindings.rd_kafka_name(client_ptr)
|
|
337
|
-
error = Rdkafka::RdkafkaError.new(err_code, broker_message: reason, instance_name: instance_name)
|
|
338
|
-
error.set_backtrace(caller)
|
|
339
|
-
Rdkafka::Config.error_callback.call(error)
|
|
340
|
-
end
|
|
341
|
-
end
|
|
342
|
-
|
|
343
|
-
# The OAuth callback is currently global and contextless. This means that the callback will be
|
|
344
|
-
# called for all instances, and the callback must be able to determine to which instance it is
|
|
345
|
-
# associated. The instance name will be provided in the callback, allowing the callback to
|
|
346
|
-
# reference the correct instance.
|
|
347
|
-
#
|
|
348
|
-
# An example of how to use the instance name in the callback is given below.
|
|
349
|
-
# The `refresh_token` is configured as the `oauthbearer_token_refresh_callback`.
|
|
350
|
-
# `instances` is a map of client names to client instances, maintained by the user.
|
|
351
|
-
#
|
|
352
|
-
# ```
|
|
353
|
-
# def refresh_token(config, client_name)
|
|
354
|
-
# client = instances[client_name]
|
|
355
|
-
# client.oauthbearer_set_token(
|
|
356
|
-
# token: 'new-token-value',
|
|
357
|
-
# lifetime_ms: token-lifetime-ms,
|
|
358
|
-
# principal_name: 'principal-name'
|
|
359
|
-
# )
|
|
360
|
-
# end
|
|
361
|
-
# ```
|
|
362
|
-
OAuthbearerTokenRefreshCallback = FFI::Function.new(
|
|
363
|
-
:void, [:pointer, :string, :pointer]
|
|
364
|
-
) do |client_ptr, config, _opaque|
|
|
365
|
-
if Rdkafka::Config.oauthbearer_token_refresh_callback && !client_ptr.null?
|
|
366
|
-
Rdkafka::Config.oauthbearer_token_refresh_callback.call(config, Rdkafka::Bindings.rd_kafka_name(client_ptr))
|
|
367
|
-
end
|
|
368
|
-
end
|
|
369
|
-
|
|
370
|
-
# Handle
|
|
371
|
-
|
|
372
|
-
enum :kafka_type, [
|
|
373
|
-
:rd_kafka_producer,
|
|
374
|
-
:rd_kafka_consumer
|
|
375
|
-
]
|
|
376
|
-
|
|
377
|
-
attach_function :rd_kafka_new, [:kafka_type, :pointer, :pointer, :int], :pointer
|
|
378
|
-
|
|
379
|
-
attach_function :rd_kafka_destroy, [:pointer], :void
|
|
380
|
-
|
|
381
|
-
# Consumer
|
|
382
|
-
|
|
383
|
-
attach_function :rd_kafka_subscribe, [:pointer, :pointer], :int, blocking: true
|
|
384
|
-
attach_function :rd_kafka_unsubscribe, [:pointer], :int, blocking: true
|
|
385
|
-
attach_function :rd_kafka_subscription, [:pointer, :pointer], :int, blocking: true
|
|
386
|
-
attach_function :rd_kafka_assign, [:pointer, :pointer], :int, blocking: true
|
|
387
|
-
attach_function :rd_kafka_incremental_assign, [:pointer, :pointer], :int, blocking: true
|
|
388
|
-
attach_function :rd_kafka_incremental_unassign, [:pointer, :pointer], :int, blocking: true
|
|
389
|
-
attach_function :rd_kafka_assignment, [:pointer, :pointer], :int, blocking: true
|
|
390
|
-
attach_function :rd_kafka_assignment_lost, [:pointer], :int, blocking: true
|
|
391
|
-
attach_function :rd_kafka_committed, [:pointer, :pointer, :int], :int, blocking: true
|
|
392
|
-
attach_function :rd_kafka_commit, [:pointer, :pointer, :bool], :int, blocking: true
|
|
393
|
-
attach_function :rd_kafka_poll_set_consumer, [:pointer], :void, blocking: true
|
|
394
|
-
attach_function :rd_kafka_consumer_poll, [:pointer, :int], :pointer, blocking: true
|
|
395
|
-
# Non-blocking consumer poll variant (does not release GVL)
|
|
396
|
-
# More efficient for poll(0) calls in fiber schedulers.
|
|
397
|
-
attach_function :rd_kafka_consumer_poll_nb, :rd_kafka_consumer_poll, [:pointer, :int], :pointer, blocking: false
|
|
398
|
-
attach_function :rd_kafka_consumer_close, [:pointer], :void, blocking: true
|
|
399
|
-
attach_function :rd_kafka_queue_get_consumer, [:pointer], :pointer
|
|
400
|
-
attach_function :rd_kafka_consume_batch_queue, [:pointer, :int, :pointer, :size_t], :ssize_t, blocking: true
|
|
401
|
-
attach_function :rd_kafka_consume_batch_queue_nb, :rd_kafka_consume_batch_queue, [:pointer, :int, :pointer, :size_t], :ssize_t, blocking: false
|
|
402
|
-
attach_function :rd_kafka_offsets_store, [:pointer, :pointer], :int, blocking: true
|
|
403
|
-
attach_function :rd_kafka_pause_partitions, [:pointer, :pointer], :int, blocking: true
|
|
404
|
-
attach_function :rd_kafka_resume_partitions, [:pointer, :pointer], :int, blocking: true
|
|
405
|
-
attach_function :rd_kafka_seek, [:pointer, :int32, :int64, :int], :int, blocking: true
|
|
406
|
-
attach_function :rd_kafka_offsets_for_times, [:pointer, :pointer, :int], :int, blocking: true
|
|
407
|
-
attach_function :rd_kafka_position, [:pointer, :pointer], :int, blocking: true
|
|
408
|
-
# those two are used for eos support
|
|
409
|
-
attach_function :rd_kafka_consumer_group_metadata, [:pointer], :pointer, blocking: true
|
|
410
|
-
attach_function :rd_kafka_consumer_group_metadata_destroy, [:pointer], :void, blocking: true
|
|
411
|
-
|
|
412
|
-
# Headers
|
|
413
|
-
attach_function :rd_kafka_header_get_all, [:pointer, :size_t, :pointer, :pointer, SizePtr], :int
|
|
414
|
-
attach_function :rd_kafka_message_headers, [:pointer, :pointer], :int
|
|
415
|
-
|
|
416
|
-
# Rebalance
|
|
417
|
-
|
|
418
|
-
callback :rebalance_cb_function, [:pointer, :int, :pointer, :pointer], :void
|
|
419
|
-
attach_function :rd_kafka_conf_set_rebalance_cb, [:pointer, :rebalance_cb_function], :void, blocking: true
|
|
420
|
-
|
|
421
|
-
RebalanceCallback = FFI::Function.new(
|
|
422
|
-
:void, [:pointer, :int, :pointer, :pointer]
|
|
423
|
-
) do |client_ptr, code, partitions_ptr, opaque_ptr|
|
|
424
|
-
case code
|
|
425
|
-
when RD_KAFKA_RESP_ERR__ASSIGN_PARTITIONS
|
|
426
|
-
if Rdkafka::Bindings.rd_kafka_rebalance_protocol(client_ptr) == "COOPERATIVE"
|
|
427
|
-
Rdkafka::Bindings.rd_kafka_incremental_assign(client_ptr, partitions_ptr)
|
|
428
|
-
else
|
|
429
|
-
Rdkafka::Bindings.rd_kafka_assign(client_ptr, partitions_ptr)
|
|
430
|
-
end
|
|
431
|
-
else # RD_KAFKA_RESP_ERR__REVOKE_PARTITIONS or errors
|
|
432
|
-
if Rdkafka::Bindings.rd_kafka_rebalance_protocol(client_ptr) == "COOPERATIVE"
|
|
433
|
-
Rdkafka::Bindings.rd_kafka_incremental_unassign(client_ptr, partitions_ptr)
|
|
434
|
-
else
|
|
435
|
-
Rdkafka::Bindings.rd_kafka_assign(client_ptr, FFI::Pointer::NULL)
|
|
436
|
-
end
|
|
437
|
-
end
|
|
438
|
-
|
|
439
|
-
opaque = Rdkafka::Config.opaques[opaque_ptr.to_i]
|
|
440
|
-
return unless opaque
|
|
441
|
-
|
|
442
|
-
tpl = Rdkafka::Consumer::TopicPartitionList.from_native_tpl(partitions_ptr).freeze
|
|
443
|
-
begin
|
|
444
|
-
case code
|
|
445
|
-
when RD_KAFKA_RESP_ERR__ASSIGN_PARTITIONS
|
|
446
|
-
opaque.call_on_partitions_assigned(tpl)
|
|
447
|
-
when RD_KAFKA_RESP_ERR__REVOKE_PARTITIONS
|
|
448
|
-
opaque.call_on_partitions_revoked(tpl)
|
|
449
|
-
end
|
|
450
|
-
rescue Exception => err
|
|
451
|
-
Rdkafka::Config.logger.error("Unhandled exception: #{err.class} - #{err.message}")
|
|
452
|
-
end
|
|
453
|
-
end
|
|
454
|
-
|
|
455
|
-
# Stats
|
|
456
|
-
|
|
457
|
-
attach_function :rd_kafka_query_watermark_offsets, [:pointer, :string, :int, :pointer, :pointer, :int], :int, blocking: true
|
|
458
|
-
|
|
459
|
-
# Producer
|
|
460
|
-
RD_KAFKA_VTYPE_END = 0
|
|
461
|
-
RD_KAFKA_VTYPE_TOPIC = 1
|
|
462
|
-
RD_KAFKA_VTYPE_RKT = 2
|
|
463
|
-
RD_KAFKA_VTYPE_PARTITION = 3
|
|
464
|
-
RD_KAFKA_VTYPE_VALUE = 4
|
|
465
|
-
RD_KAFKA_VTYPE_KEY = 5
|
|
466
|
-
RD_KAFKA_VTYPE_OPAQUE = 6
|
|
467
|
-
RD_KAFKA_VTYPE_MSGFLAGS = 7
|
|
468
|
-
RD_KAFKA_VTYPE_TIMESTAMP = 8
|
|
469
|
-
RD_KAFKA_VTYPE_HEADER = 9
|
|
470
|
-
RD_KAFKA_VTYPE_HEADERS = 10
|
|
471
|
-
RD_KAFKA_PURGE_F_QUEUE = 1
|
|
472
|
-
RD_KAFKA_PURGE_F_INFLIGHT = 2
|
|
473
|
-
|
|
474
|
-
RD_KAFKA_MSG_F_COPY = 0x2
|
|
475
|
-
|
|
476
|
-
attach_function :rd_kafka_producev, [:pointer, :varargs], :int, blocking: true
|
|
477
|
-
attach_function :rd_kafka_purge, [:pointer, :int], :int, blocking: true
|
|
478
|
-
callback :delivery_cb, [:pointer, :pointer, :pointer], :void
|
|
479
|
-
attach_function :rd_kafka_conf_set_dr_msg_cb, [:pointer, :delivery_cb], :void
|
|
480
|
-
|
|
481
|
-
# Hash mapping partitioner names to their FFI function symbols
|
|
482
|
-
# @return [Hash{String => Symbol}]
|
|
483
|
-
PARTITIONERS = %w[random consistent consistent_random murmur2 murmur2_random fnv1a fnv1a_random].each_with_object({}) do |name, hsh|
|
|
484
|
-
method_name = :"rd_kafka_msg_partitioner_#{name}"
|
|
485
|
-
attach_function method_name, [:pointer, :pointer, :size_t, :int32, :pointer, :pointer], :int32
|
|
486
|
-
hsh[name] = method_name
|
|
487
|
-
end
|
|
488
|
-
|
|
489
|
-
# Calculates the partition for a message based on the partitioner
|
|
490
|
-
#
|
|
491
|
-
# @param topic_ptr [FFI::Pointer] pointer to the topic handle
|
|
492
|
-
# @param str [String] the partition key string
|
|
493
|
-
# @param partition_count [Integer, nil] number of partitions
|
|
494
|
-
# @param partitioner [String] name of the partitioner to use
|
|
495
|
-
# @return [Integer] partition number or RD_KAFKA_PARTITION_UA if unassigned
|
|
496
|
-
# @raise [Rdkafka::Config::ConfigError] when an unknown partitioner is specified
|
|
497
|
-
def self.partitioner(topic_ptr, str, partition_count, partitioner = "consistent_random")
|
|
498
|
-
# Return RD_KAFKA_PARTITION_UA(unassigned partition) when partition count is nil/zero.
|
|
499
|
-
return RD_KAFKA_PARTITION_UA unless partition_count&.nonzero?
|
|
500
|
-
|
|
501
|
-
str_ptr = str.empty? ? FFI::MemoryPointer::NULL : FFI::MemoryPointer.from_string(str)
|
|
502
|
-
method_name = PARTITIONERS.fetch(partitioner) do
|
|
503
|
-
raise Rdkafka::Config::ConfigError.new("Unknown partitioner: #{partitioner}")
|
|
504
|
-
end
|
|
505
|
-
|
|
506
|
-
public_send(method_name, topic_ptr, str_ptr, str.size, partition_count, nil, nil)
|
|
507
|
-
end
|
|
508
|
-
|
|
509
|
-
# Create Topics
|
|
510
|
-
RD_KAFKA_ADMIN_OP_CREATETOPICS = 1 # rd_kafka_admin_op_t
|
|
511
|
-
RD_KAFKA_EVENT_CREATETOPICS_RESULT = 100 # rd_kafka_event_type_t
|
|
512
|
-
|
|
513
|
-
attach_function :rd_kafka_CreateTopics, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
|
|
514
|
-
attach_function :rd_kafka_NewTopic_new, [:pointer, :size_t, :size_t, :pointer, :size_t], :pointer, blocking: true
|
|
515
|
-
attach_function :rd_kafka_NewTopic_set_config, [:pointer, :string, :string], :int32, blocking: true
|
|
516
|
-
attach_function :rd_kafka_NewTopic_destroy, [:pointer], :void, blocking: true
|
|
517
|
-
attach_function :rd_kafka_event_CreateTopics_result, [:pointer], :pointer, blocking: true
|
|
518
|
-
attach_function :rd_kafka_CreateTopics_result_topics, [:pointer, :pointer], :pointer, blocking: true
|
|
519
|
-
|
|
520
|
-
# Delete Topics
|
|
521
|
-
RD_KAFKA_ADMIN_OP_DELETETOPICS = 2 # rd_kafka_admin_op_t
|
|
522
|
-
RD_KAFKA_EVENT_DELETETOPICS_RESULT = 101 # rd_kafka_event_type_t
|
|
523
|
-
|
|
524
|
-
attach_function :rd_kafka_DeleteTopics, [:pointer, :pointer, :size_t, :pointer, :pointer], :int32, blocking: true
|
|
525
|
-
attach_function :rd_kafka_DeleteTopic_new, [:pointer], :pointer, blocking: true
|
|
526
|
-
attach_function :rd_kafka_DeleteTopic_destroy, [:pointer], :void, blocking: true
|
|
527
|
-
attach_function :rd_kafka_event_DeleteTopics_result, [:pointer], :pointer, blocking: true
|
|
528
|
-
attach_function :rd_kafka_DeleteTopics_result_topics, [:pointer, :pointer], :pointer, blocking: true
|
|
529
|
-
|
|
530
|
-
# Create partitions
|
|
531
|
-
RD_KAFKA_ADMIN_OP_CREATEPARTITIONS = 3
|
|
532
|
-
RD_KAFKA_ADMIN_OP_CREATEPARTITIONS_RESULT = 102
|
|
533
|
-
|
|
534
|
-
attach_function :rd_kafka_CreatePartitions, [:pointer, :pointer, :size_t, :pointer, :pointer], :void
|
|
535
|
-
attach_function :rd_kafka_NewPartitions_new, %i[pointer size_t pointer size_t], :pointer
|
|
536
|
-
attach_function :rd_kafka_NewPartitions_destroy, [:pointer], :void
|
|
537
|
-
attach_function :rd_kafka_event_CreatePartitions_result, [:pointer], :pointer
|
|
538
|
-
attach_function :rd_kafka_CreatePartitions_result_topics, [:pointer, :pointer], :pointer
|
|
539
|
-
|
|
540
|
-
# Delete Group
|
|
541
|
-
RD_KAFKA_ADMIN_OP_DELETEGROUPS = 7 # rd_kafka_admin_op_t
|
|
542
|
-
RD_KAFKA_EVENT_DELETEGROUPS_RESULT = 106 # rd_kafka_event_type_t
|
|
543
|
-
|
|
544
|
-
attach_function :rd_kafka_DeleteGroups, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
|
|
545
|
-
attach_function :rd_kafka_DeleteGroup_new, [:pointer], :pointer, blocking: true
|
|
546
|
-
attach_function :rd_kafka_DeleteGroup_destroy, [:pointer], :void, blocking: true
|
|
547
|
-
attach_function :rd_kafka_event_DeleteGroups_result, [:pointer], :pointer, blocking: true # rd_kafka_event_t* => rd_kafka_DeleteGroups_result_t*
|
|
548
|
-
attach_function :rd_kafka_DeleteGroups_result_groups, [:pointer, :pointer], :pointer, blocking: true # rd_kafka_DeleteGroups_result_t*, size_t* => rd_kafka_group_result_t**
|
|
549
|
-
|
|
550
|
-
# Delete Records
|
|
551
|
-
RD_KAFKA_ADMIN_OP_DELETERECORDS = 6 # rd_kafka_admin_op_t
|
|
552
|
-
RD_KAFKA_EVENT_DELETERECORDS_RESULT = 105 # rd_kafka_event_type_t
|
|
553
|
-
|
|
554
|
-
attach_function :rd_kafka_DeleteRecords, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
|
|
555
|
-
attach_function :rd_kafka_DeleteRecords_new, [:pointer], :pointer, blocking: true
|
|
556
|
-
attach_function :rd_kafka_DeleteRecords_destroy, [:pointer], :void, blocking: true
|
|
557
|
-
attach_function :rd_kafka_event_DeleteRecords_result, [:pointer], :pointer, blocking: true # rd_kafka_event_t* => rd_kafka_DeleteRecords_result_t*
|
|
558
|
-
attach_function :rd_kafka_DeleteRecords_result_offsets, [:pointer], :pointer, blocking: true # rd_kafka_DeleteRecords_result_t* => rd_kafka_topic_partition_list_t*
|
|
559
|
-
|
|
560
|
-
# List Consumer Groups
|
|
561
|
-
RD_KAFKA_ADMIN_OP_LISTCONSUMERGROUPS = 12 # rd_kafka_admin_op_t
|
|
562
|
-
RD_KAFKA_EVENT_LISTCONSUMERGROUPS_RESULT = 0x2000 # rd_kafka_event_type_t
|
|
563
|
-
|
|
564
|
-
# Consumer group states (rd_kafka_consumer_group_state_t)
|
|
565
|
-
RD_KAFKA_CONSUMER_GROUP_STATE_UNKNOWN = 0
|
|
566
|
-
RD_KAFKA_CONSUMER_GROUP_STATE_PREPARING_REBALANCE = 1
|
|
567
|
-
RD_KAFKA_CONSUMER_GROUP_STATE_COMPLETING_REBALANCE = 2
|
|
568
|
-
RD_KAFKA_CONSUMER_GROUP_STATE_STABLE = 3
|
|
569
|
-
RD_KAFKA_CONSUMER_GROUP_STATE_DEAD = 4
|
|
570
|
-
RD_KAFKA_CONSUMER_GROUP_STATE_EMPTY = 5
|
|
571
|
-
|
|
572
|
-
attach_function :rd_kafka_ListConsumerGroups, [:pointer, :pointer, :pointer], :void, blocking: true
|
|
573
|
-
attach_function :rd_kafka_event_ListConsumerGroups_result, [:pointer], :pointer, blocking: true # rd_kafka_event_t* => rd_kafka_ListConsumerGroups_result_t*
|
|
574
|
-
attach_function :rd_kafka_ListConsumerGroups_result_valid, [:pointer, :pointer], :pointer, blocking: true # result*, size_t* => rd_kafka_ConsumerGroupListing_t**
|
|
575
|
-
attach_function :rd_kafka_ListConsumerGroups_result_errors, [:pointer, :pointer], :pointer, blocking: true # result*, size_t* => rd_kafka_error_t**
|
|
576
|
-
attach_function :rd_kafka_ConsumerGroupListing_group_id, [:pointer], :pointer, blocking: true # => const char*
|
|
577
|
-
attach_function :rd_kafka_ConsumerGroupListing_is_simple_consumer_group, [:pointer], :int, blocking: true
|
|
578
|
-
attach_function :rd_kafka_ConsumerGroupListing_state, [:pointer], :int, blocking: true
|
|
579
|
-
attach_function :rd_kafka_consumer_group_state_name, [:int], :pointer, blocking: true # => const char*
|
|
580
|
-
|
|
581
|
-
# Background Queue and Callback
|
|
582
|
-
|
|
583
|
-
attach_function :rd_kafka_conf_set_background_event_cb, [:pointer, :pointer], :void
|
|
584
|
-
attach_function :rd_kafka_queue_destroy, [:pointer], :void
|
|
585
|
-
|
|
586
|
-
# Admin Options
|
|
587
|
-
|
|
588
|
-
attach_function :rd_kafka_AdminOptions_new, [:pointer, :int32], :pointer
|
|
589
|
-
attach_function :rd_kafka_AdminOptions_set_opaque, [:pointer, :pointer], :void
|
|
590
|
-
attach_function :rd_kafka_AdminOptions_destroy, [:pointer], :void
|
|
591
|
-
|
|
592
|
-
# Extracting data from event types
|
|
593
|
-
|
|
594
|
-
attach_function :rd_kafka_event_type, [:pointer], :int32
|
|
595
|
-
attach_function :rd_kafka_event_opaque, [:pointer], :pointer
|
|
596
|
-
attach_function :rd_kafka_event_destroy, [:pointer], :void
|
|
597
|
-
|
|
598
|
-
# Extracting data from topic results
|
|
599
|
-
|
|
600
|
-
attach_function :rd_kafka_topic_result_error, [:pointer], :int32
|
|
601
|
-
attach_function :rd_kafka_topic_result_error_string, [:pointer], :pointer
|
|
602
|
-
attach_function :rd_kafka_topic_result_name, [:pointer], :pointer
|
|
603
|
-
|
|
604
|
-
# Create Acls
|
|
605
|
-
RD_KAFKA_ADMIN_OP_CREATEACLS = 9
|
|
606
|
-
RD_KAFKA_EVENT_CREATEACLS_RESULT = 1024
|
|
607
|
-
|
|
608
|
-
attach_function :rd_kafka_CreateAcls, [:pointer, :pointer, :size_t, :pointer, :pointer], :void
|
|
609
|
-
attach_function :rd_kafka_event_CreateAcls_result, [:pointer], :pointer
|
|
610
|
-
attach_function :rd_kafka_CreateAcls_result_acls, [:pointer, :pointer], :pointer
|
|
611
|
-
|
|
612
|
-
# Delete Acls
|
|
613
|
-
RD_KAFKA_ADMIN_OP_DELETEACLS = 11
|
|
614
|
-
RD_KAFKA_EVENT_DELETEACLS_RESULT = 4096
|
|
615
|
-
|
|
616
|
-
attach_function :rd_kafka_DeleteAcls, [:pointer, :pointer, :size_t, :pointer, :pointer], :void
|
|
617
|
-
attach_function :rd_kafka_event_DeleteAcls_result, [:pointer], :pointer
|
|
618
|
-
attach_function :rd_kafka_DeleteAcls_result_responses, [:pointer, :pointer], :pointer
|
|
619
|
-
attach_function :rd_kafka_DeleteAcls_result_response_error, [:pointer], :pointer
|
|
620
|
-
attach_function :rd_kafka_DeleteAcls_result_response_matching_acls, [:pointer, :pointer], :pointer
|
|
621
|
-
|
|
622
|
-
# Describe Acls
|
|
623
|
-
RD_KAFKA_ADMIN_OP_DESCRIBEACLS = 10
|
|
624
|
-
RD_KAFKA_EVENT_DESCRIBEACLS_RESULT = 2048
|
|
625
|
-
|
|
626
|
-
attach_function :rd_kafka_DescribeAcls, [:pointer, :pointer, :pointer, :pointer], :void
|
|
627
|
-
attach_function :rd_kafka_event_DescribeAcls_result, [:pointer], :pointer
|
|
628
|
-
attach_function :rd_kafka_DescribeAcls_result_acls, [:pointer, :pointer], :pointer
|
|
629
|
-
|
|
630
|
-
# Acl Bindings
|
|
631
|
-
|
|
632
|
-
attach_function :rd_kafka_AclBinding_restype, [:pointer], :int32
|
|
633
|
-
attach_function :rd_kafka_AclBinding_name, [:pointer], :pointer
|
|
634
|
-
attach_function :rd_kafka_AclBinding_resource_pattern_type, [:pointer], :int32
|
|
635
|
-
attach_function :rd_kafka_AclBinding_principal, [:pointer], :pointer
|
|
636
|
-
attach_function :rd_kafka_AclBinding_host, [:pointer], :pointer
|
|
637
|
-
attach_function :rd_kafka_AclBinding_operation, [:pointer], :int32
|
|
638
|
-
attach_function :rd_kafka_AclBinding_permission_type, [:pointer], :int32
|
|
639
|
-
attach_function :rd_kafka_AclBinding_new, [:int32, :pointer, :int32, :pointer, :pointer, :int32, :int32, :pointer, :size_t], :pointer
|
|
640
|
-
attach_function :rd_kafka_AclBindingFilter_new, [:int32, :pointer, :int32, :pointer, :pointer, :int32, :int32, :pointer, :size_t], :pointer
|
|
641
|
-
attach_function :rd_kafka_AclBinding_destroy, [:pointer], :void
|
|
642
|
-
|
|
643
|
-
# rd_kafka_ResourceType_t -
|
|
644
|
-
# https://github.com/confluentinc/librdkafka/blob/292d2a66b992/src/rdkafka.h#L7307
|
|
645
|
-
RD_KAFKA_RESOURCE_ANY = 1
|
|
646
|
-
RD_KAFKA_RESOURCE_TOPIC = 2
|
|
647
|
-
RD_KAFKA_RESOURCE_GROUP = 3
|
|
648
|
-
RD_KAFKA_RESOURCE_BROKER = 4
|
|
649
|
-
RD_KAFKA_RESOURCE_TRANSACTIONAL_ID = 5
|
|
650
|
-
|
|
651
|
-
# rd_kafka_ResourcePatternType_t -
|
|
652
|
-
# https://github.com/confluentinc/librdkafka/blob/292d2a66b992/src/rdkafka.h#L7320
|
|
653
|
-
RD_KAFKA_RESOURCE_PATTERN_UNKNOWN = 0
|
|
654
|
-
RD_KAFKA_RESOURCE_PATTERN_ANY = 1
|
|
655
|
-
RD_KAFKA_RESOURCE_PATTERN_MATCH = 2
|
|
656
|
-
RD_KAFKA_RESOURCE_PATTERN_LITERAL = 3
|
|
657
|
-
RD_KAFKA_RESOURCE_PATTERN_PREFIXED = 4
|
|
658
|
-
|
|
659
|
-
# rd_kafka_AclOperation_t -
|
|
660
|
-
# https://github.com/confluentinc/librdkafka/blob/292d2a66b992/src/rdkafka.h#L8403
|
|
661
|
-
RD_KAFKA_ACL_OPERATION_ANY = 1
|
|
662
|
-
RD_KAFKA_ACL_OPERATION_ALL = 2
|
|
663
|
-
RD_KAFKA_ACL_OPERATION_READ = 3
|
|
664
|
-
RD_KAFKA_ACL_OPERATION_WRITE = 4
|
|
665
|
-
RD_KAFKA_ACL_OPERATION_CREATE = 5
|
|
666
|
-
RD_KAFKA_ACL_OPERATION_DELETE = 6
|
|
667
|
-
RD_KAFKA_ACL_OPERATION_ALTER = 7
|
|
668
|
-
RD_KAFKA_ACL_OPERATION_DESCRIBE = 8
|
|
669
|
-
RD_KAFKA_ACL_OPERATION_CLUSTER_ACTION = 9
|
|
670
|
-
RD_KAFKA_ACL_OPERATION_DESCRIBE_CONFIGS = 10
|
|
671
|
-
RD_KAFKA_ACL_OPERATION_ALTER_CONFIGS = 11
|
|
672
|
-
RD_KAFKA_ACL_OPERATION_IDEMPOTENT_WRITE = 12
|
|
673
|
-
|
|
674
|
-
# rd_kafka_AclPermissionType_t -
|
|
675
|
-
# https://github.com/confluentinc/librdkafka/blob/292d2a66b992/src/rdkafka.h#L8435
|
|
676
|
-
RD_KAFKA_ACL_PERMISSION_TYPE_ANY = 1
|
|
677
|
-
RD_KAFKA_ACL_PERMISSION_TYPE_DENY = 2
|
|
678
|
-
RD_KAFKA_ACL_PERMISSION_TYPE_ALLOW = 3
|
|
679
|
-
|
|
680
|
-
# Extracting error details from Acl results
|
|
681
|
-
attach_function :rd_kafka_acl_result_error, [:pointer], :pointer
|
|
682
|
-
attach_function :rd_kafka_error_code, [:pointer], :int32
|
|
683
|
-
attach_function :rd_kafka_error_string, [:pointer], :pointer
|
|
684
|
-
attach_function :rd_kafka_event_error, [:pointer], :int32
|
|
685
|
-
attach_function :rd_kafka_event_error_string, [:pointer], :pointer
|
|
686
|
-
attach_function :rd_kafka_AclBinding_error, [:pointer], :pointer
|
|
687
|
-
|
|
688
|
-
# FFI struct for native error (rd_kafka_error_t)
|
|
689
|
-
class NativeError < FFI::Struct
|
|
690
|
-
layout :code, :int32,
|
|
691
|
-
:errstr, :pointer,
|
|
692
|
-
:fatal, :u_int8_t,
|
|
693
|
-
:retriable, :u_int8_t,
|
|
694
|
-
:txn_requires_abort, :u_int8_t
|
|
695
|
-
end
|
|
696
|
-
|
|
697
|
-
attach_function :rd_kafka_group_result_error, [:pointer], NativeError.by_ref # rd_kafka_group_result_t* => rd_kafka_error_t*
|
|
698
|
-
attach_function :rd_kafka_group_result_name, [:pointer], :pointer
|
|
699
87
|
end
|
|
700
88
|
end
|
|
89
|
+
|
|
90
|
+
require_relative "bindings/structs"
|
|
91
|
+
require_relative "bindings/polling"
|
|
92
|
+
require_relative "bindings/metadata"
|
|
93
|
+
require_relative "bindings/messages"
|
|
94
|
+
require_relative "bindings/errors"
|
|
95
|
+
require_relative "bindings/configuration"
|
|
96
|
+
require_relative "bindings/callbacks"
|
|
97
|
+
require_relative "bindings/handle"
|
|
98
|
+
require_relative "bindings/consumer"
|
|
99
|
+
require_relative "bindings/producer"
|
|
100
|
+
require_relative "bindings/admin"
|