karafka-rdkafka 0.27.2-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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +41 -1
- data/README.md +4 -3
- data/docker-compose-ssl.yml +1 -1
- data/docker-compose.yml +1 -1
- data/ext/librdkafka.so +0 -0
- data/karafka-rdkafka.gemspec +1 -0
- data/lib/rdkafka/abstract_handle.rb +37 -4
- data/lib/rdkafka/admin/config_binding_result.rb +1 -1
- data/lib/rdkafka/admin/create_acl_handle.rb +2 -8
- data/lib/rdkafka/admin/create_acl_report.rb +2 -1
- data/lib/rdkafka/admin/create_partitions_handle.rb +1 -20
- data/lib/rdkafka/admin/create_topic_handle.rb +1 -20
- data/lib/rdkafka/admin/delete_acl_handle.rb +2 -10
- data/lib/rdkafka/admin/delete_groups_handle.rb +3 -11
- data/lib/rdkafka/admin/delete_records_handle.rb +31 -0
- data/lib/rdkafka/admin/delete_records_report.rb +25 -0
- data/lib/rdkafka/admin/delete_topic_handle.rb +1 -20
- data/lib/rdkafka/admin/describe_acl_handle.rb +2 -10
- data/lib/rdkafka/admin/describe_acl_report.rb +2 -1
- data/lib/rdkafka/admin/describe_configs_handle.rb +2 -13
- data/lib/rdkafka/admin/describe_configs_report.rb +5 -6
- data/lib/rdkafka/admin/incremental_alter_configs_handle.rb +2 -13
- data/lib/rdkafka/admin/incremental_alter_configs_report.rb +5 -6
- data/lib/rdkafka/admin/list_consumer_groups_handle.rb +31 -0
- data/lib/rdkafka/admin/list_consumer_groups_report.rb +83 -0
- data/lib/rdkafka/admin/list_offsets_handle.rb +2 -13
- data/lib/rdkafka/admin/list_offsets_report.rb +5 -2
- data/lib/rdkafka/admin.rb +233 -145
- data/lib/rdkafka/bindings.rb +63 -16
- data/lib/rdkafka/callbacks/base_handler.rb +62 -0
- data/lib/rdkafka/callbacks/create_acl_handler.rb +37 -0
- data/lib/rdkafka/callbacks/create_partitions_handler.rb +37 -0
- data/lib/rdkafka/callbacks/create_topic_handler.rb +37 -0
- data/lib/rdkafka/callbacks/delete_acl_handler.rb +42 -0
- data/lib/rdkafka/callbacks/delete_groups_handler.rb +37 -0
- data/lib/rdkafka/callbacks/delete_records_handler.rb +38 -0
- data/lib/rdkafka/callbacks/delete_topic_handler.rb +37 -0
- data/lib/rdkafka/callbacks/describe_acl_handler.rb +35 -0
- data/lib/rdkafka/callbacks/describe_configs_handler.rb +42 -0
- data/lib/rdkafka/callbacks/incremental_alter_configs_handler.rb +42 -0
- data/lib/rdkafka/callbacks/list_consumer_groups_handler.rb +39 -0
- data/lib/rdkafka/callbacks/list_offsets_handler.rb +42 -0
- data/lib/rdkafka/callbacks.rb +60 -246
- data/lib/rdkafka/config.rb +69 -50
- data/lib/rdkafka/consumer/headers.rb +19 -5
- data/lib/rdkafka/consumer/topic_partition_list.rb +57 -42
- data/lib/rdkafka/consumer.rb +190 -48
- data/lib/rdkafka/defaults.rb +32 -3
- data/lib/rdkafka/error.rb +14 -5
- data/lib/rdkafka/helpers/list_offsets.rb +127 -0
- data/lib/rdkafka/helpers/metadata.rb +29 -0
- data/lib/rdkafka/helpers/oauth.rb +10 -5
- data/lib/rdkafka/metadata.rb +84 -19
- data/lib/rdkafka/native_kafka.rb +20 -7
- data/lib/rdkafka/producer/delivery_handle.rb +4 -5
- data/lib/rdkafka/producer/partitions_count_cache.rb +24 -38
- data/lib/rdkafka/producer/testing.rb +2 -1
- data/lib/rdkafka/producer.rb +100 -71
- data/lib/rdkafka/version.rb +3 -3
- data/lib/rdkafka.rb +19 -0
- data/package-lock.json +6 -6
- data/renovate.json +11 -1
- metadata +21 -5
- data/Gemfile +0 -13
- data/Gemfile.lint +0 -14
- data/Gemfile.lint.lock +0 -123
data/lib/rdkafka/bindings.rb
CHANGED
|
@@ -58,6 +58,7 @@ module Rdkafka
|
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
+
RD_KAFKA_RESP_ERR__TIMED_OUT = -185
|
|
61
62
|
RD_KAFKA_RESP_ERR__ASSIGN_PARTITIONS = -175
|
|
62
63
|
RD_KAFKA_RESP_ERR__REVOKE_PARTITIONS = -174
|
|
63
64
|
RD_KAFKA_RESP_ERR__STATE = -172
|
|
@@ -87,7 +88,7 @@ module Rdkafka
|
|
|
87
88
|
|
|
88
89
|
# This function comes from our patch on top of librdkafka. It allows os to load all the
|
|
89
90
|
# librdkafka components without initializing the client
|
|
90
|
-
#
|
|
91
|
+
# See: https://github.com/confluentinc/librdkafka/issues/4590
|
|
91
92
|
attach_function :rd_kafka_global_init, [], :void
|
|
92
93
|
|
|
93
94
|
# Polling
|
|
@@ -105,8 +106,12 @@ module Rdkafka
|
|
|
105
106
|
# Metadata
|
|
106
107
|
|
|
107
108
|
attach_function :rd_kafka_name, [:pointer], :string
|
|
108
|
-
|
|
109
|
-
|
|
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
|
|
110
115
|
attach_function :rd_kafka_metadata, [:pointer, :int, :pointer, :pointer, :int], :int, blocking: true
|
|
111
116
|
attach_function :rd_kafka_metadata_destroy, [:pointer], :void, blocking: true
|
|
112
117
|
|
|
@@ -242,6 +247,8 @@ module Rdkafka
|
|
|
242
247
|
|
|
243
248
|
attach_function :rd_kafka_conf_new, [], :pointer
|
|
244
249
|
attach_function :rd_kafka_conf_set, [:pointer, :string, :string, :pointer, :int], :kafka_config_response
|
|
250
|
+
attach_function :rd_kafka_conf_get, [:pointer, :string, :pointer, :pointer], :kafka_config_response
|
|
251
|
+
attach_function :rd_kafka_conf, [:pointer], :pointer
|
|
245
252
|
attach_function :rd_kafka_conf_dump, [:pointer, :pointer], :pointer
|
|
246
253
|
attach_function :rd_kafka_conf_dump_free, [:pointer, :size_t], :void
|
|
247
254
|
attach_function :rd_kafka_conf_destroy, [:pointer], :void
|
|
@@ -264,13 +271,15 @@ module Rdkafka
|
|
|
264
271
|
|
|
265
272
|
# Queue IO Event Support - for fiber scheduler integration
|
|
266
273
|
# Enables notifications to a custom FD when queue transitions from empty to non-empty
|
|
267
|
-
#
|
|
268
|
-
#
|
|
269
|
-
#
|
|
270
|
-
#
|
|
274
|
+
# Arguments:
|
|
275
|
+
# - queue (rd_kafka_queue_t*) - the queue to monitor
|
|
276
|
+
# - fd (int) - file descriptor to write to (provide your own pipe/eventfd)
|
|
277
|
+
# - payload (const void*) - data to write to fd
|
|
278
|
+
# - size (size_t) - size of payload
|
|
271
279
|
attach_function :rd_kafka_queue_io_event_enable, [:pointer, :int, :pointer, :size_t], :void
|
|
272
280
|
# Per topic configs
|
|
273
281
|
attach_function :rd_kafka_topic_conf_new, [], :pointer
|
|
282
|
+
attach_function :rd_kafka_topic_conf_destroy, [:pointer], :void
|
|
274
283
|
attach_function :rd_kafka_topic_conf_set, [:pointer, :string, :string, :pointer, :int], :kafka_config_response
|
|
275
284
|
|
|
276
285
|
LogCallback = FFI::Function.new(
|
|
@@ -335,7 +344,8 @@ module Rdkafka
|
|
|
335
344
|
# across different parts of the codebase (callbacks, testing utilities, etc.).
|
|
336
345
|
#
|
|
337
346
|
# @param client_ptr [FFI::Pointer] Native kafka client pointer
|
|
338
|
-
# @return [Hash, nil] Hash with :error_code and :error_string if fatal error occurred,
|
|
347
|
+
# @return [Hash, nil] Hash with :error_code and :error_string if fatal error occurred,
|
|
348
|
+
# nil otherwise
|
|
339
349
|
#
|
|
340
350
|
# @example
|
|
341
351
|
# details = Rdkafka::Bindings.extract_fatal_error(client_ptr)
|
|
@@ -380,9 +390,10 @@ module Rdkafka
|
|
|
380
390
|
end
|
|
381
391
|
end
|
|
382
392
|
|
|
383
|
-
# The OAuth callback is currently global and contextless.
|
|
384
|
-
#
|
|
385
|
-
# The instance name will be provided in the callback, allowing the callback to
|
|
393
|
+
# The OAuth callback is currently global and contextless. This means that the callback will be
|
|
394
|
+
# called for all instances, and the callback must be able to determine to which instance it is
|
|
395
|
+
# associated. The instance name will be provided in the callback, allowing the callback to
|
|
396
|
+
# reference the correct instance.
|
|
386
397
|
#
|
|
387
398
|
# An example of how to use the instance name in the callback is given below.
|
|
388
399
|
# The `refresh_token` is configured as the `oauthbearer_token_refresh_callback`.
|
|
@@ -493,7 +504,7 @@ module Rdkafka
|
|
|
493
504
|
|
|
494
505
|
# Stats
|
|
495
506
|
|
|
496
|
-
attach_function :rd_kafka_query_watermark_offsets, [:pointer, :string, :int, :pointer, :pointer, :int], :int
|
|
507
|
+
attach_function :rd_kafka_query_watermark_offsets, [:pointer, :string, :int, :pointer, :pointer, :int], :int, blocking: true
|
|
497
508
|
|
|
498
509
|
# Producer
|
|
499
510
|
RD_KAFKA_VTYPE_END = 0
|
|
@@ -591,6 +602,37 @@ module Rdkafka
|
|
|
591
602
|
attach_function :rd_kafka_event_DeleteGroups_result, [:pointer], :pointer, blocking: true # rd_kafka_event_t* => rd_kafka_DeleteGroups_result_t*
|
|
592
603
|
attach_function :rd_kafka_DeleteGroups_result_groups, [:pointer, :pointer], :pointer, blocking: true # rd_kafka_DeleteGroups_result_t*, size_t* => rd_kafka_group_result_t**
|
|
593
604
|
|
|
605
|
+
# Delete Records
|
|
606
|
+
RD_KAFKA_ADMIN_OP_DELETERECORDS = 6 # rd_kafka_admin_op_t
|
|
607
|
+
RD_KAFKA_EVENT_DELETERECORDS_RESULT = 105 # rd_kafka_event_type_t
|
|
608
|
+
|
|
609
|
+
attach_function :rd_kafka_DeleteRecords, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
|
|
610
|
+
attach_function :rd_kafka_DeleteRecords_new, [:pointer], :pointer, blocking: true
|
|
611
|
+
attach_function :rd_kafka_DeleteRecords_destroy, [:pointer], :void, blocking: true
|
|
612
|
+
attach_function :rd_kafka_event_DeleteRecords_result, [:pointer], :pointer, blocking: true # rd_kafka_event_t* => rd_kafka_DeleteRecords_result_t*
|
|
613
|
+
attach_function :rd_kafka_DeleteRecords_result_offsets, [:pointer], :pointer, blocking: true # rd_kafka_DeleteRecords_result_t* => rd_kafka_topic_partition_list_t*
|
|
614
|
+
|
|
615
|
+
# List Consumer Groups
|
|
616
|
+
RD_KAFKA_ADMIN_OP_LISTCONSUMERGROUPS = 12 # rd_kafka_admin_op_t
|
|
617
|
+
RD_KAFKA_EVENT_LISTCONSUMERGROUPS_RESULT = 0x2000 # rd_kafka_event_type_t
|
|
618
|
+
|
|
619
|
+
# Consumer group states (rd_kafka_consumer_group_state_t)
|
|
620
|
+
RD_KAFKA_CONSUMER_GROUP_STATE_UNKNOWN = 0
|
|
621
|
+
RD_KAFKA_CONSUMER_GROUP_STATE_PREPARING_REBALANCE = 1
|
|
622
|
+
RD_KAFKA_CONSUMER_GROUP_STATE_COMPLETING_REBALANCE = 2
|
|
623
|
+
RD_KAFKA_CONSUMER_GROUP_STATE_STABLE = 3
|
|
624
|
+
RD_KAFKA_CONSUMER_GROUP_STATE_DEAD = 4
|
|
625
|
+
RD_KAFKA_CONSUMER_GROUP_STATE_EMPTY = 5
|
|
626
|
+
|
|
627
|
+
attach_function :rd_kafka_ListConsumerGroups, [:pointer, :pointer, :pointer], :void, blocking: true
|
|
628
|
+
attach_function :rd_kafka_event_ListConsumerGroups_result, [:pointer], :pointer, blocking: true # rd_kafka_event_t* => rd_kafka_ListConsumerGroups_result_t*
|
|
629
|
+
attach_function :rd_kafka_ListConsumerGroups_result_valid, [:pointer, :pointer], :pointer, blocking: true # result*, size_t* => rd_kafka_ConsumerGroupListing_t**
|
|
630
|
+
attach_function :rd_kafka_ListConsumerGroups_result_errors, [:pointer, :pointer], :pointer, blocking: true # result*, size_t* => rd_kafka_error_t**
|
|
631
|
+
attach_function :rd_kafka_ConsumerGroupListing_group_id, [:pointer], :pointer, blocking: true # => const char*
|
|
632
|
+
attach_function :rd_kafka_ConsumerGroupListing_is_simple_consumer_group, [:pointer], :int, blocking: true
|
|
633
|
+
attach_function :rd_kafka_ConsumerGroupListing_state, [:pointer], :int, blocking: true
|
|
634
|
+
attach_function :rd_kafka_consumer_group_state_name, [:int], :pointer, blocking: true # => const char*
|
|
635
|
+
|
|
594
636
|
# Background Queue and Callback
|
|
595
637
|
|
|
596
638
|
attach_function :rd_kafka_conf_set_background_event_cb, [:pointer, :pointer], :void
|
|
@@ -606,6 +648,7 @@ module Rdkafka
|
|
|
606
648
|
|
|
607
649
|
attach_function :rd_kafka_event_type, [:pointer], :int32
|
|
608
650
|
attach_function :rd_kafka_event_opaque, [:pointer], :pointer
|
|
651
|
+
attach_function :rd_kafka_event_destroy, [:pointer], :void
|
|
609
652
|
|
|
610
653
|
# Extracting data from topic results
|
|
611
654
|
|
|
@@ -652,21 +695,24 @@ module Rdkafka
|
|
|
652
695
|
attach_function :rd_kafka_AclBindingFilter_new, [:int32, :pointer, :int32, :pointer, :pointer, :int32, :int32, :pointer, :size_t], :pointer
|
|
653
696
|
attach_function :rd_kafka_AclBinding_destroy, [:pointer], :void
|
|
654
697
|
|
|
655
|
-
# rd_kafka_ResourceType_t -
|
|
698
|
+
# rd_kafka_ResourceType_t -
|
|
699
|
+
# https://github.com/confluentinc/librdkafka/blob/292d2a66b992/src/rdkafka.h#L7307
|
|
656
700
|
RD_KAFKA_RESOURCE_ANY = 1
|
|
657
701
|
RD_KAFKA_RESOURCE_TOPIC = 2
|
|
658
702
|
RD_KAFKA_RESOURCE_GROUP = 3
|
|
659
703
|
RD_KAFKA_RESOURCE_BROKER = 4
|
|
660
704
|
RD_KAFKA_RESOURCE_TRANSACTIONAL_ID = 5
|
|
661
705
|
|
|
662
|
-
# rd_kafka_ResourcePatternType_t -
|
|
706
|
+
# rd_kafka_ResourcePatternType_t -
|
|
707
|
+
# https://github.com/confluentinc/librdkafka/blob/292d2a66b992/src/rdkafka.h#L7320
|
|
663
708
|
RD_KAFKA_RESOURCE_PATTERN_UNKNOWN = 0
|
|
664
709
|
RD_KAFKA_RESOURCE_PATTERN_ANY = 1
|
|
665
710
|
RD_KAFKA_RESOURCE_PATTERN_MATCH = 2
|
|
666
711
|
RD_KAFKA_RESOURCE_PATTERN_LITERAL = 3
|
|
667
712
|
RD_KAFKA_RESOURCE_PATTERN_PREFIXED = 4
|
|
668
713
|
|
|
669
|
-
# rd_kafka_AclOperation_t -
|
|
714
|
+
# rd_kafka_AclOperation_t -
|
|
715
|
+
# https://github.com/confluentinc/librdkafka/blob/292d2a66b992/src/rdkafka.h#L8403
|
|
670
716
|
RD_KAFKA_ACL_OPERATION_ANY = 1
|
|
671
717
|
RD_KAFKA_ACL_OPERATION_ALL = 2
|
|
672
718
|
RD_KAFKA_ACL_OPERATION_READ = 3
|
|
@@ -680,7 +726,8 @@ module Rdkafka
|
|
|
680
726
|
RD_KAFKA_ACL_OPERATION_ALTER_CONFIGS = 11
|
|
681
727
|
RD_KAFKA_ACL_OPERATION_IDEMPOTENT_WRITE = 12
|
|
682
728
|
|
|
683
|
-
# rd_kafka_AclPermissionType_t -
|
|
729
|
+
# rd_kafka_AclPermissionType_t -
|
|
730
|
+
# https://github.com/confluentinc/librdkafka/blob/292d2a66b992/src/rdkafka.h#L8435
|
|
684
731
|
RD_KAFKA_ACL_PERMISSION_TYPE_ANY = 1
|
|
685
732
|
RD_KAFKA_ACL_PERMISSION_TYPE_DENY = 2
|
|
686
733
|
RD_KAFKA_ACL_PERMISSION_TYPE_ALLOW = 3
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Callbacks
|
|
5
|
+
# Base class for admin background-event result handlers.
|
|
6
|
+
#
|
|
7
|
+
# Each subclass handles one librdkafka admin result event type: it extracts the result from
|
|
8
|
+
# the event, looks up the matching {AbstractHandle} in the registry and resolves it (sets the
|
|
9
|
+
# response, builds the report, copies the broker message, then unlocks it).
|
|
10
|
+
#
|
|
11
|
+
# The event is owned by the application and destroyed by {BackgroundEventCallback} right after
|
|
12
|
+
# dispatch, so handlers must copy everything they need out of event-owned memory into Ruby
|
|
13
|
+
# objects before returning.
|
|
14
|
+
#
|
|
15
|
+
# @private
|
|
16
|
+
class BaseHandler
|
|
17
|
+
class << self
|
|
18
|
+
# Processes a background event for the operation this handler is responsible for.
|
|
19
|
+
# @param event_ptr [FFI::Pointer] pointer to the event
|
|
20
|
+
# @return [void]
|
|
21
|
+
def call(event_ptr)
|
|
22
|
+
raise NotImplementedError, "#{name} must implement .call"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
# Copies an event-owned C string into a Ruby string
|
|
28
|
+
# @param ptr [FFI::Pointer] pointer to the C string
|
|
29
|
+
# @return [String, nil] copied string or nil when NULL
|
|
30
|
+
def read_event_string(ptr)
|
|
31
|
+
ptr.null? ? nil : ptr.read_string
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Resolves a handle directly from an operation-level event error and unlocks it.
|
|
35
|
+
#
|
|
36
|
+
# librdkafka signals a failure of the whole admin operation (e.g. `_TIMED_OUT` when the
|
|
37
|
+
# brokers are unreachable, or `_DESTROY` when the client is closed with the request in
|
|
38
|
+
# flight) by setting the event error and delivering an *empty* results array. The
|
|
39
|
+
# per-element result handlers must not index into that empty array; they call this first
|
|
40
|
+
# and skip results parsing when it returns true. Without this, indexing `results[0]`
|
|
41
|
+
# raises inside the FFI callback, the handle is never unlocked, and the caller's `wait`
|
|
42
|
+
# blocks until its own timeout and raises `WaitTimeoutError`, losing the real error code.
|
|
43
|
+
#
|
|
44
|
+
# @param event_ptr [FFI::Pointer] pointer to the event
|
|
45
|
+
# @param handle [Rdkafka::AbstractHandle] the handle to resolve
|
|
46
|
+
# @return [Boolean] true when the event carried an operation-level error and the handle
|
|
47
|
+
# was resolved here
|
|
48
|
+
def resolve_operation_error(event_ptr, handle)
|
|
49
|
+
error_code = Rdkafka::Bindings.rd_kafka_event_error(event_ptr)
|
|
50
|
+
|
|
51
|
+
return false if error_code == Rdkafka::Bindings::RD_KAFKA_RESP_ERR_NO_ERROR
|
|
52
|
+
|
|
53
|
+
handle[:response] = error_code
|
|
54
|
+
handle.broker_message = read_event_string(Rdkafka::Bindings.rd_kafka_event_error_string(event_ptr))
|
|
55
|
+
handle.unlock
|
|
56
|
+
|
|
57
|
+
true
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Callbacks
|
|
5
|
+
# Handles `RD_KAFKA_EVENT_CREATEACLS_RESULT` events
|
|
6
|
+
# @private
|
|
7
|
+
class CreateAclHandler < BaseHandler
|
|
8
|
+
class << self
|
|
9
|
+
# Resolves the create-ACL handle from its result event
|
|
10
|
+
# @param event_ptr [FFI::Pointer] pointer to the event
|
|
11
|
+
# @return [void]
|
|
12
|
+
def call(event_ptr)
|
|
13
|
+
create_acls_result = Rdkafka::Bindings.rd_kafka_event_CreateAcls_result(event_ptr)
|
|
14
|
+
|
|
15
|
+
# Get the number of acl results
|
|
16
|
+
pointer_to_size_t = FFI::MemoryPointer.new(:size_t)
|
|
17
|
+
create_acl_result_array = Rdkafka::Bindings.rd_kafka_CreateAcls_result_acls(create_acls_result, pointer_to_size_t)
|
|
18
|
+
create_acl_results = CreateAclResult.create_acl_results_from_array(pointer_to_size_t.read_int, create_acl_result_array)
|
|
19
|
+
create_acl_handle_ptr = Rdkafka::Bindings.rd_kafka_event_opaque(event_ptr)
|
|
20
|
+
|
|
21
|
+
if create_acl_handle = Rdkafka::Admin::CreateAclHandle.remove(create_acl_handle_ptr.address)
|
|
22
|
+
unless resolve_operation_error(event_ptr, create_acl_handle)
|
|
23
|
+
create_acl_handle[:response] = create_acl_results[0].result_error
|
|
24
|
+
create_acl_handle.result = Rdkafka::Admin::CreateAclReport.new(
|
|
25
|
+
rdkafka_response: create_acl_results[0].result_error,
|
|
26
|
+
rdkafka_response_string: create_acl_results[0].error_string
|
|
27
|
+
)
|
|
28
|
+
create_acl_handle.broker_message = create_acl_handle.result.rdkafka_response_string
|
|
29
|
+
|
|
30
|
+
create_acl_handle.unlock
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Callbacks
|
|
5
|
+
# Handles `RD_KAFKA_ADMIN_OP_CREATEPARTITIONS_RESULT` events
|
|
6
|
+
# @private
|
|
7
|
+
class CreatePartitionsHandler < BaseHandler
|
|
8
|
+
class << self
|
|
9
|
+
# Resolves the create-partitions handle from its result event
|
|
10
|
+
# @param event_ptr [FFI::Pointer] pointer to the event
|
|
11
|
+
# @return [void]
|
|
12
|
+
def call(event_ptr)
|
|
13
|
+
create_partitionss_result = Rdkafka::Bindings.rd_kafka_event_CreatePartitions_result(event_ptr)
|
|
14
|
+
|
|
15
|
+
# Get the number of create topic results
|
|
16
|
+
pointer_to_size_t = FFI::MemoryPointer.new(:size_t)
|
|
17
|
+
create_partitions_result_array = Rdkafka::Bindings.rd_kafka_CreatePartitions_result_topics(create_partitionss_result, pointer_to_size_t)
|
|
18
|
+
create_partitions_results = TopicResult.create_topic_results_from_array(pointer_to_size_t.read_int, create_partitions_result_array)
|
|
19
|
+
create_partitions_handle_ptr = Rdkafka::Bindings.rd_kafka_event_opaque(event_ptr)
|
|
20
|
+
|
|
21
|
+
if create_partitions_handle = Rdkafka::Admin::CreatePartitionsHandle.remove(create_partitions_handle_ptr.address)
|
|
22
|
+
unless resolve_operation_error(event_ptr, create_partitions_handle)
|
|
23
|
+
create_partitions_handle[:response] = create_partitions_results[0].result_error
|
|
24
|
+
create_partitions_handle.result = Rdkafka::Admin::CreatePartitionsReport.new(
|
|
25
|
+
create_partitions_results[0].error_string,
|
|
26
|
+
create_partitions_results[0].result_name
|
|
27
|
+
)
|
|
28
|
+
create_partitions_handle.broker_message = create_partitions_handle.result.error_string
|
|
29
|
+
|
|
30
|
+
create_partitions_handle.unlock
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Callbacks
|
|
5
|
+
# Handles `RD_KAFKA_EVENT_CREATETOPICS_RESULT` events
|
|
6
|
+
# @private
|
|
7
|
+
class CreateTopicHandler < BaseHandler
|
|
8
|
+
class << self
|
|
9
|
+
# Resolves the create-topic handle from its result event
|
|
10
|
+
# @param event_ptr [FFI::Pointer] pointer to the event
|
|
11
|
+
# @return [void]
|
|
12
|
+
def call(event_ptr)
|
|
13
|
+
create_topics_result = Rdkafka::Bindings.rd_kafka_event_CreateTopics_result(event_ptr)
|
|
14
|
+
|
|
15
|
+
# Get the number of create topic results
|
|
16
|
+
pointer_to_size_t = FFI::MemoryPointer.new(:size_t)
|
|
17
|
+
create_topic_result_array = Rdkafka::Bindings.rd_kafka_CreateTopics_result_topics(create_topics_result, pointer_to_size_t)
|
|
18
|
+
create_topic_results = TopicResult.create_topic_results_from_array(pointer_to_size_t.read_int, create_topic_result_array)
|
|
19
|
+
create_topic_handle_ptr = Rdkafka::Bindings.rd_kafka_event_opaque(event_ptr)
|
|
20
|
+
|
|
21
|
+
if create_topic_handle = Rdkafka::Admin::CreateTopicHandle.remove(create_topic_handle_ptr.address)
|
|
22
|
+
unless resolve_operation_error(event_ptr, create_topic_handle)
|
|
23
|
+
create_topic_handle[:response] = create_topic_results[0].result_error
|
|
24
|
+
create_topic_handle.result = Rdkafka::Admin::CreateTopicReport.new(
|
|
25
|
+
create_topic_results[0].error_string,
|
|
26
|
+
create_topic_results[0].result_name
|
|
27
|
+
)
|
|
28
|
+
create_topic_handle.broker_message = create_topic_handle.result.error_string
|
|
29
|
+
|
|
30
|
+
create_topic_handle.unlock
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Callbacks
|
|
5
|
+
# Handles `RD_KAFKA_EVENT_DELETEACLS_RESULT` events
|
|
6
|
+
# @private
|
|
7
|
+
class DeleteAclHandler < BaseHandler
|
|
8
|
+
class << self
|
|
9
|
+
# Resolves the delete-ACL handle from its result event
|
|
10
|
+
# @param event_ptr [FFI::Pointer] pointer to the event
|
|
11
|
+
# @return [void]
|
|
12
|
+
def call(event_ptr)
|
|
13
|
+
delete_acls_result = Rdkafka::Bindings.rd_kafka_event_DeleteAcls_result(event_ptr)
|
|
14
|
+
|
|
15
|
+
# Get the number of acl results
|
|
16
|
+
pointer_to_size_t = FFI::MemoryPointer.new(:size_t)
|
|
17
|
+
delete_acl_result_responses = Rdkafka::Bindings.rd_kafka_DeleteAcls_result_responses(delete_acls_result, pointer_to_size_t)
|
|
18
|
+
delete_acl_results = DeleteAclResult.delete_acl_results_from_array(pointer_to_size_t.read_int, delete_acl_result_responses)
|
|
19
|
+
delete_acl_handle_ptr = Rdkafka::Bindings.rd_kafka_event_opaque(event_ptr)
|
|
20
|
+
|
|
21
|
+
if delete_acl_handle = Rdkafka::Admin::DeleteAclHandle.remove(delete_acl_handle_ptr.address)
|
|
22
|
+
unless resolve_operation_error(event_ptr, delete_acl_handle)
|
|
23
|
+
delete_acl_handle[:response] = delete_acl_results[0].result_error
|
|
24
|
+
delete_acl_handle.broker_message = read_event_string(delete_acl_results[0].error_string)
|
|
25
|
+
|
|
26
|
+
delete_acl_handle.result = if delete_acl_results[0].result_error == Rdkafka::Bindings::RD_KAFKA_RESP_ERR_NO_ERROR
|
|
27
|
+
Rdkafka::Admin::DeleteAclReport.new(
|
|
28
|
+
matching_acls: delete_acl_results[0].matching_acls,
|
|
29
|
+
matching_acls_count: delete_acl_results[0].matching_acls_count
|
|
30
|
+
)
|
|
31
|
+
else
|
|
32
|
+
Rdkafka::Admin::DeleteAclReport.new(matching_acls: FFI::Pointer::NULL, matching_acls_count: 0)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
delete_acl_handle.unlock
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Callbacks
|
|
5
|
+
# Handles `RD_KAFKA_EVENT_DELETEGROUPS_RESULT` events
|
|
6
|
+
# @private
|
|
7
|
+
class DeleteGroupsHandler < BaseHandler
|
|
8
|
+
class << self
|
|
9
|
+
# Resolves the delete-groups handle from its result event
|
|
10
|
+
# @param event_ptr [FFI::Pointer] pointer to the event
|
|
11
|
+
# @return [void]
|
|
12
|
+
def call(event_ptr)
|
|
13
|
+
delete_groups_result = Rdkafka::Bindings.rd_kafka_event_DeleteGroups_result(event_ptr)
|
|
14
|
+
|
|
15
|
+
# Get the number of delete group results
|
|
16
|
+
pointer_to_size_t = FFI::MemoryPointer.new(:size_t)
|
|
17
|
+
delete_group_result_array = Rdkafka::Bindings.rd_kafka_DeleteGroups_result_groups(delete_groups_result, pointer_to_size_t)
|
|
18
|
+
delete_group_results = GroupResult.create_group_results_from_array(pointer_to_size_t.read_int, delete_group_result_array)
|
|
19
|
+
delete_group_handle_ptr = Rdkafka::Bindings.rd_kafka_event_opaque(event_ptr)
|
|
20
|
+
|
|
21
|
+
if (delete_group_handle = Rdkafka::Admin::DeleteGroupsHandle.remove(delete_group_handle_ptr.address))
|
|
22
|
+
unless resolve_operation_error(event_ptr, delete_group_handle)
|
|
23
|
+
delete_group_handle[:response] = delete_group_results[0].result_error
|
|
24
|
+
delete_group_handle.result = Rdkafka::Admin::DeleteGroupsReport.new(
|
|
25
|
+
delete_group_results[0].error_string,
|
|
26
|
+
delete_group_results[0].result_name
|
|
27
|
+
)
|
|
28
|
+
delete_group_handle.broker_message = delete_group_handle.result.error_string
|
|
29
|
+
|
|
30
|
+
delete_group_handle.unlock
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Callbacks
|
|
5
|
+
# Handles `RD_KAFKA_EVENT_DELETERECORDS_RESULT` events
|
|
6
|
+
# @private
|
|
7
|
+
class DeleteRecordsHandler < BaseHandler
|
|
8
|
+
class << self
|
|
9
|
+
# Resolves the delete-records handle from its result event
|
|
10
|
+
# @param event_ptr [FFI::Pointer] pointer to the event
|
|
11
|
+
# @return [void]
|
|
12
|
+
def call(event_ptr)
|
|
13
|
+
result_ptr = Rdkafka::Bindings.rd_kafka_event_DeleteRecords_result(event_ptr)
|
|
14
|
+
handle_ptr = Rdkafka::Bindings.rd_kafka_event_opaque(event_ptr)
|
|
15
|
+
|
|
16
|
+
return unless (handle = Rdkafka::Admin::DeleteRecordsHandle.remove(handle_ptr.address))
|
|
17
|
+
|
|
18
|
+
# An operation-level error (e.g. timeout or a closed client) is delivered on the event
|
|
19
|
+
# itself, with no per-partition result to parse.
|
|
20
|
+
return if resolve_operation_error(event_ptr, handle)
|
|
21
|
+
|
|
22
|
+
handle[:response] = Rdkafka::Bindings::RD_KAFKA_RESP_ERR_NO_ERROR
|
|
23
|
+
|
|
24
|
+
# Parsing must copy everything out of event-owned memory before the event is destroyed.
|
|
25
|
+
# An exception here is captured and re-raised on the waiting thread, since it cannot
|
|
26
|
+
# unwind through librdkafka native frames.
|
|
27
|
+
handle.result = begin
|
|
28
|
+
Rdkafka::Admin::DeleteRecordsReport.new(result_ptr)
|
|
29
|
+
rescue => e
|
|
30
|
+
e
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
handle.unlock
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Callbacks
|
|
5
|
+
# Handles `RD_KAFKA_EVENT_DELETETOPICS_RESULT` events
|
|
6
|
+
# @private
|
|
7
|
+
class DeleteTopicHandler < BaseHandler
|
|
8
|
+
class << self
|
|
9
|
+
# Resolves the delete-topic handle from its result event
|
|
10
|
+
# @param event_ptr [FFI::Pointer] pointer to the event
|
|
11
|
+
# @return [void]
|
|
12
|
+
def call(event_ptr)
|
|
13
|
+
delete_topics_result = Rdkafka::Bindings.rd_kafka_event_DeleteTopics_result(event_ptr)
|
|
14
|
+
|
|
15
|
+
# Get the number of topic results
|
|
16
|
+
pointer_to_size_t = FFI::MemoryPointer.new(:size_t)
|
|
17
|
+
delete_topic_result_array = Rdkafka::Bindings.rd_kafka_DeleteTopics_result_topics(delete_topics_result, pointer_to_size_t)
|
|
18
|
+
delete_topic_results = TopicResult.create_topic_results_from_array(pointer_to_size_t.read_int, delete_topic_result_array)
|
|
19
|
+
delete_topic_handle_ptr = Rdkafka::Bindings.rd_kafka_event_opaque(event_ptr)
|
|
20
|
+
|
|
21
|
+
if delete_topic_handle = Rdkafka::Admin::DeleteTopicHandle.remove(delete_topic_handle_ptr.address)
|
|
22
|
+
unless resolve_operation_error(event_ptr, delete_topic_handle)
|
|
23
|
+
delete_topic_handle[:response] = delete_topic_results[0].result_error
|
|
24
|
+
delete_topic_handle.result = Rdkafka::Admin::DeleteTopicReport.new(
|
|
25
|
+
delete_topic_results[0].error_string,
|
|
26
|
+
delete_topic_results[0].result_name
|
|
27
|
+
)
|
|
28
|
+
delete_topic_handle.broker_message = delete_topic_handle.result.error_string
|
|
29
|
+
|
|
30
|
+
delete_topic_handle.unlock
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Callbacks
|
|
5
|
+
# Handles `RD_KAFKA_EVENT_DESCRIBEACLS_RESULT` events
|
|
6
|
+
# @private
|
|
7
|
+
class DescribeAclHandler < BaseHandler
|
|
8
|
+
class << self
|
|
9
|
+
# Resolves the describe-ACL handle from its result event
|
|
10
|
+
# @param event_ptr [FFI::Pointer] pointer to the event
|
|
11
|
+
# @return [void]
|
|
12
|
+
def call(event_ptr)
|
|
13
|
+
describe_acl = DescribeAclResult.new(event_ptr)
|
|
14
|
+
describe_acl_handle_ptr = Rdkafka::Bindings.rd_kafka_event_opaque(event_ptr)
|
|
15
|
+
|
|
16
|
+
if describe_acl_handle = Rdkafka::Admin::DescribeAclHandle.remove(describe_acl_handle_ptr.address)
|
|
17
|
+
describe_acl_handle[:response] = describe_acl.result_error
|
|
18
|
+
describe_acl_handle.broker_message = read_event_string(describe_acl.error_string)
|
|
19
|
+
|
|
20
|
+
describe_acl_handle.result = if describe_acl.result_error == Rdkafka::Bindings::RD_KAFKA_RESP_ERR_NO_ERROR
|
|
21
|
+
Rdkafka::Admin::DescribeAclReport.new(
|
|
22
|
+
acls: describe_acl.matching_acls,
|
|
23
|
+
acls_count: describe_acl.matching_acls_count
|
|
24
|
+
)
|
|
25
|
+
else
|
|
26
|
+
Rdkafka::Admin::DescribeAclReport.new(acls: FFI::Pointer::NULL, acls_count: 0)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe_acl_handle.unlock
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Callbacks
|
|
5
|
+
# Handles `RD_KAFKA_EVENT_DESCRIBECONFIGS_RESULT` events
|
|
6
|
+
# @private
|
|
7
|
+
class DescribeConfigsHandler < BaseHandler
|
|
8
|
+
class << self
|
|
9
|
+
# Resolves the describe-configs handle from its result event
|
|
10
|
+
# @param event_ptr [FFI::Pointer] pointer to the event
|
|
11
|
+
# @return [void]
|
|
12
|
+
def call(event_ptr)
|
|
13
|
+
describe_configs = DescribeConfigsResult.new(event_ptr)
|
|
14
|
+
describe_configs_handle_ptr = Rdkafka::Bindings.rd_kafka_event_opaque(event_ptr)
|
|
15
|
+
|
|
16
|
+
if describe_configs_handle = Rdkafka::Admin::DescribeConfigsHandle.remove(describe_configs_handle_ptr.address)
|
|
17
|
+
describe_configs_handle[:response] = describe_configs.result_error
|
|
18
|
+
describe_configs_handle.broker_message = read_event_string(describe_configs.error_string)
|
|
19
|
+
|
|
20
|
+
# Parsing can raise on per-resource errors. The exception is captured and re-raised on
|
|
21
|
+
# the waiting thread, since an exception leaving this callback would unwind through
|
|
22
|
+
# librdkafka native frames
|
|
23
|
+
describe_configs_handle.result = begin
|
|
24
|
+
if describe_configs.result_error == Rdkafka::Bindings::RD_KAFKA_RESP_ERR_NO_ERROR
|
|
25
|
+
Rdkafka::Admin::DescribeConfigsReport.new(
|
|
26
|
+
config_entries: describe_configs.results,
|
|
27
|
+
entry_count: describe_configs.results_count
|
|
28
|
+
)
|
|
29
|
+
else
|
|
30
|
+
Rdkafka::Admin::DescribeConfigsReport.new(config_entries: FFI::Pointer::NULL, entry_count: 0)
|
|
31
|
+
end
|
|
32
|
+
rescue => e
|
|
33
|
+
e
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe_configs_handle.unlock
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Callbacks
|
|
5
|
+
# Handles `RD_KAFKA_EVENT_INCREMENTALALTERCONFIGS_RESULT` events
|
|
6
|
+
# @private
|
|
7
|
+
class IncrementalAlterConfigsHandler < BaseHandler
|
|
8
|
+
class << self
|
|
9
|
+
# Resolves the incremental-alter-configs handle from its result event
|
|
10
|
+
# @param event_ptr [FFI::Pointer] pointer to the event
|
|
11
|
+
# @return [void]
|
|
12
|
+
def call(event_ptr)
|
|
13
|
+
incremental_alter = IncrementalAlterConfigsResult.new(event_ptr)
|
|
14
|
+
incremental_alter_handle_ptr = Rdkafka::Bindings.rd_kafka_event_opaque(event_ptr)
|
|
15
|
+
|
|
16
|
+
if incremental_alter_handle = Rdkafka::Admin::IncrementalAlterConfigsHandle.remove(incremental_alter_handle_ptr.address)
|
|
17
|
+
incremental_alter_handle[:response] = incremental_alter.result_error
|
|
18
|
+
incremental_alter_handle.broker_message = read_event_string(incremental_alter.error_string)
|
|
19
|
+
|
|
20
|
+
# Parsing can raise on per-resource errors. The exception is captured and re-raised on
|
|
21
|
+
# the waiting thread, since an exception leaving this callback would unwind through
|
|
22
|
+
# librdkafka native frames
|
|
23
|
+
incremental_alter_handle.result = begin
|
|
24
|
+
if incremental_alter.result_error == Rdkafka::Bindings::RD_KAFKA_RESP_ERR_NO_ERROR
|
|
25
|
+
Rdkafka::Admin::IncrementalAlterConfigsReport.new(
|
|
26
|
+
config_entries: incremental_alter.results,
|
|
27
|
+
entry_count: incremental_alter.results_count
|
|
28
|
+
)
|
|
29
|
+
else
|
|
30
|
+
Rdkafka::Admin::IncrementalAlterConfigsReport.new(config_entries: FFI::Pointer::NULL, entry_count: 0)
|
|
31
|
+
end
|
|
32
|
+
rescue => e
|
|
33
|
+
e
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
incremental_alter_handle.unlock
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|