rdkafka 0.22.2 → 0.27.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 +63 -3
- data/Gemfile +8 -0
- data/Gemfile.lint +14 -0
- data/Gemfile.lint.lock +123 -0
- data/README.md +19 -14
- data/Rakefile +21 -21
- data/bin/verify_kafka_warnings +39 -0
- data/dist/{librdkafka-2.8.0.tar.gz → librdkafka-2.14.0.tar.gz} +0 -0
- data/docker-compose-ssl.yml +35 -0
- data/docker-compose.yml +2 -2
- data/ext/Rakefile +27 -27
- data/lib/rdkafka/abstract_handle.rb +23 -5
- data/lib/rdkafka/admin/acl_binding_result.rb +5 -5
- data/lib/rdkafka/admin/config_resource_binding_result.rb +1 -0
- data/lib/rdkafka/admin/create_acl_handle.rb +7 -4
- data/lib/rdkafka/admin/create_acl_report.rb +3 -2
- data/lib/rdkafka/admin/create_partitions_handle.rb +8 -5
- data/lib/rdkafka/admin/create_partitions_report.rb +1 -0
- data/lib/rdkafka/admin/create_topic_handle.rb +8 -5
- data/lib/rdkafka/admin/create_topic_report.rb +3 -0
- data/lib/rdkafka/admin/delete_acl_handle.rb +9 -6
- data/lib/rdkafka/admin/delete_acl_report.rb +5 -3
- data/lib/rdkafka/admin/delete_groups_handle.rb +10 -5
- data/lib/rdkafka/admin/delete_groups_report.rb +3 -0
- data/lib/rdkafka/admin/delete_topic_handle.rb +8 -5
- data/lib/rdkafka/admin/delete_topic_report.rb +3 -0
- data/lib/rdkafka/admin/describe_acl_handle.rb +9 -6
- data/lib/rdkafka/admin/describe_acl_report.rb +5 -3
- data/lib/rdkafka/admin/describe_configs_handle.rb +7 -4
- data/lib/rdkafka/admin/describe_configs_report.rb +7 -1
- data/lib/rdkafka/admin/incremental_alter_configs_handle.rb +7 -4
- data/lib/rdkafka/admin/incremental_alter_configs_report.rb +7 -1
- data/lib/rdkafka/admin/list_offsets_handle.rb +36 -0
- data/lib/rdkafka/admin/list_offsets_report.rb +51 -0
- data/lib/rdkafka/admin.rb +301 -135
- data/lib/rdkafka/bindings.rb +199 -110
- data/lib/rdkafka/callbacks.rb +124 -21
- data/lib/rdkafka/config.rb +81 -33
- data/lib/rdkafka/consumer/headers.rb +3 -2
- data/lib/rdkafka/consumer/message.rb +12 -11
- data/lib/rdkafka/consumer/partition.rb +8 -4
- data/lib/rdkafka/consumer/topic_partition_list.rb +21 -17
- data/lib/rdkafka/consumer.rb +397 -45
- data/lib/rdkafka/defaults.rb +106 -0
- data/lib/rdkafka/error.rb +40 -14
- data/lib/rdkafka/helpers/oauth.rb +45 -13
- data/lib/rdkafka/helpers/time.rb +5 -0
- data/lib/rdkafka/metadata.rb +45 -21
- data/lib/rdkafka/native_kafka.rb +89 -4
- data/lib/rdkafka/producer/delivery_handle.rb +5 -5
- data/lib/rdkafka/producer/delivery_report.rb +10 -6
- data/lib/rdkafka/producer/partitions_count_cache.rb +29 -19
- data/lib/rdkafka/producer.rb +168 -82
- data/lib/rdkafka/version.rb +6 -3
- data/lib/rdkafka.rb +3 -0
- data/package-lock.json +331 -0
- data/package.json +9 -0
- data/rdkafka.gemspec +57 -36
- data/renovate.json +29 -24
- metadata +29 -124
- data/.github/CODEOWNERS +0 -3
- data/.github/FUNDING.yml +0 -1
- data/.github/workflows/ci_linux_x86_64_gnu.yml +0 -271
- data/.github/workflows/ci_linux_x86_64_musl.yml +0 -194
- data/.github/workflows/ci_macos_arm64.yml +0 -284
- data/.github/workflows/push_linux_x86_64_gnu.yml +0 -65
- data/.github/workflows/push_linux_x86_64_musl.yml +0 -79
- data/.github/workflows/push_macos_arm64.yml +0 -54
- data/.github/workflows/push_ruby.yml +0 -37
- data/.github/workflows/verify-action-pins.yml +0 -16
- data/.gitignore +0 -14
- data/.rspec +0 -2
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.yardopts +0 -2
- data/ext/README.md +0 -19
- data/ext/build_common.sh +0 -361
- data/ext/build_linux_x86_64_gnu.sh +0 -306
- data/ext/build_linux_x86_64_musl.sh +0 -763
- data/ext/build_macos_arm64.sh +0 -550
- data/spec/rdkafka/abstract_handle_spec.rb +0 -117
- data/spec/rdkafka/admin/create_acl_handle_spec.rb +0 -56
- data/spec/rdkafka/admin/create_acl_report_spec.rb +0 -18
- data/spec/rdkafka/admin/create_topic_handle_spec.rb +0 -52
- data/spec/rdkafka/admin/create_topic_report_spec.rb +0 -16
- data/spec/rdkafka/admin/delete_acl_handle_spec.rb +0 -85
- data/spec/rdkafka/admin/delete_acl_report_spec.rb +0 -72
- data/spec/rdkafka/admin/delete_topic_handle_spec.rb +0 -52
- data/spec/rdkafka/admin/delete_topic_report_spec.rb +0 -16
- data/spec/rdkafka/admin/describe_acl_handle_spec.rb +0 -85
- data/spec/rdkafka/admin/describe_acl_report_spec.rb +0 -73
- data/spec/rdkafka/admin_spec.rb +0 -971
- data/spec/rdkafka/bindings_spec.rb +0 -199
- data/spec/rdkafka/callbacks_spec.rb +0 -20
- data/spec/rdkafka/config_spec.rb +0 -258
- data/spec/rdkafka/consumer/headers_spec.rb +0 -73
- data/spec/rdkafka/consumer/message_spec.rb +0 -139
- data/spec/rdkafka/consumer/partition_spec.rb +0 -57
- data/spec/rdkafka/consumer/topic_partition_list_spec.rb +0 -248
- data/spec/rdkafka/consumer_spec.rb +0 -1274
- data/spec/rdkafka/error_spec.rb +0 -89
- data/spec/rdkafka/metadata_spec.rb +0 -79
- data/spec/rdkafka/native_kafka_spec.rb +0 -130
- data/spec/rdkafka/producer/delivery_handle_spec.rb +0 -45
- data/spec/rdkafka/producer/delivery_report_spec.rb +0 -25
- data/spec/rdkafka/producer/partitions_count_cache_spec.rb +0 -359
- data/spec/rdkafka/producer_spec.rb +0 -1345
- data/spec/spec_helper.rb +0 -195
|
@@ -54,16 +54,34 @@ module Rdkafka
|
|
|
54
54
|
# If there is a timeout this does not mean the operation failed, rdkafka might still be working
|
|
55
55
|
# on the operation. In this case it is possible to call wait again.
|
|
56
56
|
#
|
|
57
|
-
# @param max_wait_timeout [Numeric, nil]
|
|
58
|
-
#
|
|
57
|
+
# @param max_wait_timeout [Numeric, nil] DEPRECATED: Use max_wait_timeout_ms instead.
|
|
58
|
+
# Amount of time in seconds to wait before timing out. Will be removed in v1.0.0.
|
|
59
|
+
# @param max_wait_timeout_ms [Numeric, nil] Amount of time in milliseconds to wait before
|
|
60
|
+
# timing out. If this is nil we will wait forever. Defaults to 60,000ms (60 seconds).
|
|
59
61
|
# @param raise_response_error [Boolean] should we raise error when waiting finishes
|
|
60
62
|
#
|
|
61
63
|
# @return [Object] Operation-specific result
|
|
62
64
|
#
|
|
63
65
|
# @raise [RdkafkaError] When the operation failed
|
|
64
66
|
# @raise [WaitTimeoutError] When the timeout has been reached and the handle is still pending
|
|
65
|
-
def wait(max_wait_timeout:
|
|
66
|
-
|
|
67
|
+
def wait(max_wait_timeout: :not_provided, max_wait_timeout_ms: :not_provided, raise_response_error: true)
|
|
68
|
+
# Determine which timeout value to use
|
|
69
|
+
if max_wait_timeout != :not_provided && max_wait_timeout_ms != :not_provided
|
|
70
|
+
warn "DEPRECATION WARNING: Both max_wait_timeout and max_wait_timeout_ms were provided. " \
|
|
71
|
+
"Using max_wait_timeout_ms. The max_wait_timeout parameter is deprecated and will be removed in v1.0.0."
|
|
72
|
+
timeout_ms = max_wait_timeout_ms
|
|
73
|
+
elsif max_wait_timeout != :not_provided
|
|
74
|
+
warn "DEPRECATION WARNING: max_wait_timeout (seconds) is deprecated. " \
|
|
75
|
+
"Use max_wait_timeout_ms (milliseconds) instead. This parameter will be removed in v1.0.0."
|
|
76
|
+
timeout_ms = max_wait_timeout ? (max_wait_timeout * 1000).to_i : nil
|
|
77
|
+
elsif max_wait_timeout_ms == :not_provided
|
|
78
|
+
timeout_ms = Defaults::HANDLE_WAIT_TIMEOUT_MS
|
|
79
|
+
else
|
|
80
|
+
timeout_ms = max_wait_timeout_ms
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
timeout_s = timeout_ms ? timeout_ms / 1000.0 : nil
|
|
84
|
+
timeout = timeout_s ? monotonic_now + timeout_s : MAX_WAIT_TIMEOUT_FOREVER
|
|
67
85
|
|
|
68
86
|
@mutex.synchronize do
|
|
69
87
|
loop do
|
|
@@ -74,7 +92,7 @@ module Rdkafka
|
|
|
74
92
|
@resource.wait(@mutex, to_wait)
|
|
75
93
|
else
|
|
76
94
|
raise WaitTimeoutError.new(
|
|
77
|
-
"Waiting for #{operation_name} timed out after #{
|
|
95
|
+
"Waiting for #{operation_name} timed out after #{timeout_ms} ms"
|
|
78
96
|
)
|
|
79
97
|
end
|
|
80
98
|
elsif self[:response] != 0 && raise_response_error
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
module Rdkafka
|
|
4
4
|
class Admin
|
|
5
5
|
# Extracts attributes of rd_kafka_AclBinding_t
|
|
6
|
-
#
|
|
7
6
|
class AclBindingResult
|
|
8
7
|
attr_reader :result_error, :error_string, :matching_acl_resource_type,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
:matching_acl_resource_name, :matching_acl_resource_pattern_type,
|
|
9
|
+
:matching_acl_principal, :matching_acl_host, :matching_acl_operation,
|
|
10
|
+
:matching_acl_permission_type
|
|
12
11
|
|
|
13
12
|
# This attribute was initially released under the name that is now an alias
|
|
14
13
|
# We keep it for backwards compatibility but it was changed for the consistency
|
|
15
|
-
|
|
14
|
+
alias_method :matching_acl_pattern_type, :matching_acl_resource_pattern_type
|
|
16
15
|
|
|
16
|
+
# @param matching_acl [FFI::Pointer] pointer to the ACL binding struct
|
|
17
17
|
def initialize(matching_acl)
|
|
18
18
|
rd_kafka_error_pointer = Rdkafka::Bindings.rd_kafka_AclBinding_error(matching_acl)
|
|
19
19
|
@result_error = Rdkafka::Bindings.rd_kafka_error_code(rd_kafka_error_pointer)
|
|
@@ -6,6 +6,7 @@ module Rdkafka
|
|
|
6
6
|
class ConfigResourceBindingResult
|
|
7
7
|
attr_reader :name, :type, :configs, :configs_count
|
|
8
8
|
|
|
9
|
+
# @param config_resource_ptr [FFI::Pointer] pointer to the config resource struct
|
|
9
10
|
def initialize(config_resource_ptr)
|
|
10
11
|
ffi_binding = Bindings::ConfigResource.new(config_resource_ptr)
|
|
11
12
|
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
module Rdkafka
|
|
4
4
|
class Admin
|
|
5
|
+
# Handle for create ACL operation
|
|
5
6
|
class CreateAclHandle < AbstractHandle
|
|
6
7
|
layout :pending, :bool,
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
:response, :int,
|
|
9
|
+
:response_string, :pointer
|
|
9
10
|
|
|
10
11
|
# @return [String] the name of the operation
|
|
11
12
|
def operation_name
|
|
@@ -17,10 +18,12 @@ module Rdkafka
|
|
|
17
18
|
CreateAclReport.new(rdkafka_response: self[:response], rdkafka_response_string: self[:response_string])
|
|
18
19
|
end
|
|
19
20
|
|
|
21
|
+
# Raises an error if the operation failed
|
|
22
|
+
# @raise [RdkafkaError]
|
|
20
23
|
def raise_error
|
|
21
24
|
raise RdkafkaError.new(
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
self[:response],
|
|
26
|
+
broker_message: self[:response_string].read_string
|
|
24
27
|
)
|
|
25
28
|
end
|
|
26
29
|
end
|
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
module Rdkafka
|
|
4
4
|
class Admin
|
|
5
|
+
# Report for create ACL operation result
|
|
5
6
|
class CreateAclReport
|
|
6
|
-
|
|
7
7
|
# Upon successful creation of Acl RD_KAFKA_RESP_ERR_NO_ERROR - 0 is returned as rdkafka_response
|
|
8
8
|
# @return [Integer]
|
|
9
9
|
attr_reader :rdkafka_response
|
|
10
10
|
|
|
11
|
-
|
|
12
11
|
# Upon successful creation of Acl empty string will be returned as rdkafka_response_string
|
|
13
12
|
# @return [String]
|
|
14
13
|
attr_reader :rdkafka_response_string
|
|
15
14
|
|
|
15
|
+
# @param rdkafka_response [Integer] response code from librdkafka
|
|
16
|
+
# @param rdkafka_response_string [FFI::Pointer] pointer to response string
|
|
16
17
|
def initialize(rdkafka_response:, rdkafka_response_string:)
|
|
17
18
|
@rdkafka_response = rdkafka_response
|
|
18
19
|
if rdkafka_response_string != FFI::Pointer::NULL
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
module Rdkafka
|
|
2
2
|
class Admin
|
|
3
|
+
# Handle for create partitions operation
|
|
3
4
|
class CreatePartitionsHandle < AbstractHandle
|
|
4
5
|
layout :pending, :bool,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
:response, :int,
|
|
7
|
+
:error_string, :pointer,
|
|
8
|
+
:result_name, :pointer
|
|
8
9
|
|
|
9
10
|
# @return [String] the name of the operation
|
|
10
11
|
def operation_name
|
|
@@ -16,10 +17,12 @@ module Rdkafka
|
|
|
16
17
|
CreatePartitionsReport.new(self[:error_string], self[:result_name])
|
|
17
18
|
end
|
|
18
19
|
|
|
20
|
+
# Raises an error if the operation failed
|
|
21
|
+
# @raise [RdkafkaError]
|
|
19
22
|
def raise_error
|
|
20
23
|
raise RdkafkaError.new(
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
self[:response],
|
|
25
|
+
broker_message: CreateTopicReport.new(self[:error_string], self[:result_name]).error_string
|
|
23
26
|
)
|
|
24
27
|
end
|
|
25
28
|
end
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
module Rdkafka
|
|
4
4
|
class Admin
|
|
5
|
+
# Handle for create topic operation
|
|
5
6
|
class CreateTopicHandle < AbstractHandle
|
|
6
7
|
layout :pending, :bool,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
:response, :int,
|
|
9
|
+
:error_string, :pointer,
|
|
10
|
+
:result_name, :pointer
|
|
10
11
|
|
|
11
12
|
# @return [String] the name of the operation
|
|
12
13
|
def operation_name
|
|
@@ -18,10 +19,12 @@ module Rdkafka
|
|
|
18
19
|
CreateTopicReport.new(self[:error_string], self[:result_name])
|
|
19
20
|
end
|
|
20
21
|
|
|
22
|
+
# Raises an error if the operation failed
|
|
23
|
+
# @raise [RdkafkaError]
|
|
21
24
|
def raise_error
|
|
22
25
|
raise RdkafkaError.new(
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
self[:response],
|
|
27
|
+
broker_message: CreateTopicReport.new(self[:error_string], self[:result_name]).error_string
|
|
25
28
|
)
|
|
26
29
|
end
|
|
27
30
|
end
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Rdkafka
|
|
4
4
|
class Admin
|
|
5
|
+
# Report for create topic operation result
|
|
5
6
|
class CreateTopicReport
|
|
6
7
|
# Any error message generated from the CreateTopic
|
|
7
8
|
# @return [String]
|
|
@@ -11,6 +12,8 @@ module Rdkafka
|
|
|
11
12
|
# @return [String]
|
|
12
13
|
attr_reader :result_name
|
|
13
14
|
|
|
15
|
+
# @param error_string [FFI::Pointer] pointer to error string
|
|
16
|
+
# @param result_name [FFI::Pointer] pointer to topic name
|
|
14
17
|
def initialize(error_string, result_name)
|
|
15
18
|
if error_string != FFI::Pointer::NULL
|
|
16
19
|
@error_string = error_string.read_string
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
module Rdkafka
|
|
4
4
|
class Admin
|
|
5
|
+
# Handle for delete ACL operation
|
|
5
6
|
class DeleteAclHandle < AbstractHandle
|
|
6
7
|
layout :pending, :bool,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
:response, :int,
|
|
9
|
+
:response_string, :pointer,
|
|
10
|
+
:matching_acls, :pointer,
|
|
11
|
+
:matching_acls_count, :int
|
|
11
12
|
|
|
12
13
|
# @return [String] the name of the operation
|
|
13
14
|
def operation_name
|
|
@@ -19,10 +20,12 @@ module Rdkafka
|
|
|
19
20
|
DeleteAclReport.new(matching_acls: self[:matching_acls], matching_acls_count: self[:matching_acls_count])
|
|
20
21
|
end
|
|
21
22
|
|
|
23
|
+
# Raises an error if the operation failed
|
|
24
|
+
# @raise [RdkafkaError]
|
|
22
25
|
def raise_error
|
|
23
26
|
raise RdkafkaError.new(
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
self[:response],
|
|
28
|
+
broker_message: self[:response_string].read_string
|
|
26
29
|
)
|
|
27
30
|
end
|
|
28
31
|
end
|
|
@@ -2,16 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
module Rdkafka
|
|
4
4
|
class Admin
|
|
5
|
+
# Report for delete ACL operation result
|
|
5
6
|
class DeleteAclReport
|
|
6
|
-
|
|
7
7
|
# deleted acls
|
|
8
8
|
# @return [Rdkafka::Bindings::AclBindingResult]
|
|
9
9
|
attr_reader :deleted_acls
|
|
10
10
|
|
|
11
|
+
# @param matching_acls [FFI::Pointer] pointer to matching ACLs array
|
|
12
|
+
# @param matching_acls_count [Integer] number of matching ACLs
|
|
11
13
|
def initialize(matching_acls:, matching_acls_count:)
|
|
12
|
-
@deleted_acls=[]
|
|
14
|
+
@deleted_acls = []
|
|
13
15
|
if matching_acls != FFI::Pointer::NULL
|
|
14
|
-
acl_binding_result_pointers
|
|
16
|
+
acl_binding_result_pointers = matching_acls.read_array_of_pointer(matching_acls_count)
|
|
15
17
|
(1..matching_acls_count).map do |matching_acl_index|
|
|
16
18
|
acl_binding_result = AclBindingResult.new(acl_binding_result_pointers[matching_acl_index - 1])
|
|
17
19
|
@deleted_acls << acl_binding_result
|
|
@@ -2,25 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
module Rdkafka
|
|
4
4
|
class Admin
|
|
5
|
+
# Handle for delete groups operation
|
|
5
6
|
class DeleteGroupsHandle < AbstractHandle
|
|
6
7
|
layout :pending, :bool, # TODO: ???
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
:response, :int,
|
|
9
|
+
:error_string, :pointer,
|
|
10
|
+
:result_name, :pointer
|
|
10
11
|
|
|
11
12
|
# @return [String] the name of the operation
|
|
12
13
|
def operation_name
|
|
13
14
|
"delete groups"
|
|
14
15
|
end
|
|
15
16
|
|
|
17
|
+
# Creates the result report
|
|
18
|
+
# @return [DeleteGroupsReport]
|
|
16
19
|
def create_result
|
|
17
20
|
DeleteGroupsReport.new(self[:error_string], self[:result_name])
|
|
18
21
|
end
|
|
19
22
|
|
|
23
|
+
# Raises an error if the operation failed
|
|
24
|
+
# @raise [RdkafkaError]
|
|
20
25
|
def raise_error
|
|
21
26
|
raise RdkafkaError.new(
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
self[:response],
|
|
28
|
+
broker_message: create_result.error_string
|
|
24
29
|
)
|
|
25
30
|
end
|
|
26
31
|
end
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Rdkafka
|
|
4
4
|
class Admin
|
|
5
|
+
# Report for delete groups operation result
|
|
5
6
|
class DeleteGroupsReport
|
|
6
7
|
# Any error message generated from the DeleteTopic
|
|
7
8
|
# @return [String]
|
|
@@ -11,6 +12,8 @@ module Rdkafka
|
|
|
11
12
|
# @return [String]
|
|
12
13
|
attr_reader :result_name
|
|
13
14
|
|
|
15
|
+
# @param error_string [FFI::Pointer] pointer to error string
|
|
16
|
+
# @param result_name [FFI::Pointer] pointer to group name
|
|
14
17
|
def initialize(error_string, result_name)
|
|
15
18
|
if error_string != FFI::Pointer::NULL
|
|
16
19
|
@error_string = error_string.read_string
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
module Rdkafka
|
|
4
4
|
class Admin
|
|
5
|
+
# Handle for delete topic operation
|
|
5
6
|
class DeleteTopicHandle < AbstractHandle
|
|
6
7
|
layout :pending, :bool,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
:response, :int,
|
|
9
|
+
:error_string, :pointer,
|
|
10
|
+
:result_name, :pointer
|
|
10
11
|
|
|
11
12
|
# @return [String] the name of the operation
|
|
12
13
|
def operation_name
|
|
@@ -18,10 +19,12 @@ module Rdkafka
|
|
|
18
19
|
DeleteTopicReport.new(self[:error_string], self[:result_name])
|
|
19
20
|
end
|
|
20
21
|
|
|
22
|
+
# Raises an error if the operation failed
|
|
23
|
+
# @raise [RdkafkaError]
|
|
21
24
|
def raise_error
|
|
22
25
|
raise RdkafkaError.new(
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
self[:response],
|
|
27
|
+
broker_message: DeleteTopicReport.new(self[:error_string], self[:result_name]).error_string
|
|
25
28
|
)
|
|
26
29
|
end
|
|
27
30
|
end
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Rdkafka
|
|
4
4
|
class Admin
|
|
5
|
+
# Report for delete topic operation result
|
|
5
6
|
class DeleteTopicReport
|
|
6
7
|
# Any error message generated from the DeleteTopic
|
|
7
8
|
# @return [String]
|
|
@@ -11,6 +12,8 @@ module Rdkafka
|
|
|
11
12
|
# @return [String]
|
|
12
13
|
attr_reader :result_name
|
|
13
14
|
|
|
15
|
+
# @param error_string [FFI::Pointer] pointer to error string
|
|
16
|
+
# @param result_name [FFI::Pointer] pointer to topic name
|
|
14
17
|
def initialize(error_string, result_name)
|
|
15
18
|
if error_string != FFI::Pointer::NULL
|
|
16
19
|
@error_string = error_string.read_string
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
module Rdkafka
|
|
4
4
|
class Admin
|
|
5
|
+
# Handle for describe ACL operation
|
|
5
6
|
class DescribeAclHandle < AbstractHandle
|
|
6
7
|
layout :pending, :bool,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
:response, :int,
|
|
9
|
+
:response_string, :pointer,
|
|
10
|
+
:acls, :pointer,
|
|
11
|
+
:acls_count, :int
|
|
11
12
|
|
|
12
13
|
# @return [String] the name of the operation.
|
|
13
14
|
def operation_name
|
|
@@ -19,10 +20,12 @@ module Rdkafka
|
|
|
19
20
|
DescribeAclReport.new(acls: self[:acls], acls_count: self[:acls_count])
|
|
20
21
|
end
|
|
21
22
|
|
|
23
|
+
# Raises an error if the operation failed
|
|
24
|
+
# @raise [RdkafkaError]
|
|
22
25
|
def raise_error
|
|
23
26
|
raise RdkafkaError.new(
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
self[:response],
|
|
28
|
+
broker_message: self[:response_string].read_string
|
|
26
29
|
)
|
|
27
30
|
end
|
|
28
31
|
end
|
|
@@ -2,17 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
module Rdkafka
|
|
4
4
|
class Admin
|
|
5
|
+
# Report for describe ACL operation result
|
|
5
6
|
class DescribeAclReport
|
|
6
|
-
|
|
7
7
|
# acls that exists in the cluster for the resource_type, resource_name and pattern_type filters provided in the request.
|
|
8
8
|
# @return [Rdkafka::Bindings::AclBindingResult] array of matching acls.
|
|
9
9
|
attr_reader :acls
|
|
10
10
|
|
|
11
|
+
# @param acls [FFI::Pointer] pointer to ACLs array
|
|
12
|
+
# @param acls_count [Integer] number of ACLs
|
|
11
13
|
def initialize(acls:, acls_count:)
|
|
12
|
-
@acls=[]
|
|
14
|
+
@acls = []
|
|
13
15
|
|
|
14
16
|
if acls != FFI::Pointer::NULL
|
|
15
|
-
acl_binding_result_pointers
|
|
17
|
+
acl_binding_result_pointers = acls.read_array_of_pointer(acls_count)
|
|
16
18
|
(1..acls_count).map do |acl_index|
|
|
17
19
|
acl_binding_result = AclBindingResult.new(acl_binding_result_pointers[acl_index - 1])
|
|
18
20
|
@acls << acl_binding_result
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
module Rdkafka
|
|
4
4
|
class Admin
|
|
5
|
+
# Handle for describe configs operation
|
|
5
6
|
class DescribeConfigsHandle < AbstractHandle
|
|
6
7
|
layout :pending, :bool,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
:response, :int,
|
|
9
|
+
:response_string, :pointer,
|
|
10
|
+
:config_entries, :pointer,
|
|
11
|
+
:entry_count, :int
|
|
11
12
|
|
|
12
13
|
# @return [String] the name of the operation.
|
|
13
14
|
def operation_name
|
|
@@ -22,6 +23,8 @@ module Rdkafka
|
|
|
22
23
|
)
|
|
23
24
|
end
|
|
24
25
|
|
|
26
|
+
# Raises an error if the operation failed
|
|
27
|
+
# @raise [RdkafkaError]
|
|
25
28
|
def raise_error
|
|
26
29
|
raise RdkafkaError.new(
|
|
27
30
|
self[:response],
|
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
module Rdkafka
|
|
4
4
|
class Admin
|
|
5
|
+
# Report for describe configs operation result
|
|
5
6
|
class DescribeConfigsReport
|
|
6
7
|
attr_reader :resources
|
|
7
8
|
|
|
9
|
+
# @param config_entries [FFI::Pointer] pointer to config entries array
|
|
10
|
+
# @param entry_count [Integer] number of config entries
|
|
8
11
|
def initialize(config_entries:, entry_count:)
|
|
9
|
-
@resources=[]
|
|
12
|
+
@resources = []
|
|
10
13
|
|
|
11
14
|
return if config_entries == FFI::Pointer::NULL
|
|
12
15
|
|
|
@@ -37,6 +40,9 @@ module Rdkafka
|
|
|
37
40
|
|
|
38
41
|
private
|
|
39
42
|
|
|
43
|
+
# Validates the config resource result and raises an error if invalid
|
|
44
|
+
# @param config_resource_result_ptr [FFI::Pointer] pointer to the config resource result
|
|
45
|
+
# @raise [RdkafkaError] when the config resource has an error
|
|
40
46
|
def validate!(config_resource_result_ptr)
|
|
41
47
|
code = Bindings.rd_kafka_ConfigResource_error(config_resource_result_ptr)
|
|
42
48
|
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
module Rdkafka
|
|
4
4
|
class Admin
|
|
5
|
+
# Handle for incremental alter configs operation
|
|
5
6
|
class IncrementalAlterConfigsHandle < AbstractHandle
|
|
6
7
|
layout :pending, :bool,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
:response, :int,
|
|
9
|
+
:response_string, :pointer,
|
|
10
|
+
:config_entries, :pointer,
|
|
11
|
+
:entry_count, :int
|
|
11
12
|
|
|
12
13
|
# @return [String] the name of the operation.
|
|
13
14
|
def operation_name
|
|
@@ -22,6 +23,8 @@ module Rdkafka
|
|
|
22
23
|
)
|
|
23
24
|
end
|
|
24
25
|
|
|
26
|
+
# Raises an error if the operation failed
|
|
27
|
+
# @raise [RdkafkaError]
|
|
25
28
|
def raise_error
|
|
26
29
|
raise RdkafkaError.new(
|
|
27
30
|
self[:response],
|
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
module Rdkafka
|
|
4
4
|
class Admin
|
|
5
|
+
# Report for incremental alter configs operation result
|
|
5
6
|
class IncrementalAlterConfigsReport
|
|
6
7
|
attr_reader :resources
|
|
7
8
|
|
|
9
|
+
# @param config_entries [FFI::Pointer] pointer to config entries array
|
|
10
|
+
# @param entry_count [Integer] number of config entries
|
|
8
11
|
def initialize(config_entries:, entry_count:)
|
|
9
|
-
@resources=[]
|
|
12
|
+
@resources = []
|
|
10
13
|
|
|
11
14
|
return if config_entries == FFI::Pointer::NULL
|
|
12
15
|
|
|
@@ -37,6 +40,9 @@ module Rdkafka
|
|
|
37
40
|
|
|
38
41
|
private
|
|
39
42
|
|
|
43
|
+
# Validates the config resource result and raises an error if invalid
|
|
44
|
+
# @param config_resource_result_ptr [FFI::Pointer] pointer to the config resource result
|
|
45
|
+
# @raise [RdkafkaError] when the config resource has an error
|
|
40
46
|
def validate!(config_resource_result_ptr)
|
|
41
47
|
code = Bindings.rd_kafka_ConfigResource_error(config_resource_result_ptr)
|
|
42
48
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
class Admin
|
|
5
|
+
# Handle for list offsets operation
|
|
6
|
+
class ListOffsetsHandle < AbstractHandle
|
|
7
|
+
layout :pending, :bool,
|
|
8
|
+
:response, :int,
|
|
9
|
+
:response_string, :pointer,
|
|
10
|
+
:result_infos, :pointer,
|
|
11
|
+
:result_count, :int
|
|
12
|
+
|
|
13
|
+
# @return [String] the name of the operation.
|
|
14
|
+
def operation_name
|
|
15
|
+
"list offsets"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# @return [ListOffsetsReport] instance with partition offset information.
|
|
19
|
+
def create_result
|
|
20
|
+
ListOffsetsReport.new(
|
|
21
|
+
result_infos: self[:result_infos],
|
|
22
|
+
result_count: self[:result_count]
|
|
23
|
+
)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Raises an error if the operation failed
|
|
27
|
+
# @raise [RdkafkaError]
|
|
28
|
+
def raise_error
|
|
29
|
+
raise RdkafkaError.new(
|
|
30
|
+
self[:response],
|
|
31
|
+
broker_message: self[:response_string].read_string
|
|
32
|
+
)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
class Admin
|
|
5
|
+
# Report for list offsets operation result
|
|
6
|
+
class ListOffsetsReport
|
|
7
|
+
attr_reader :offsets
|
|
8
|
+
|
|
9
|
+
# @param result_infos [FFI::Pointer] pointer to result info array
|
|
10
|
+
# @param result_count [Integer] number of result info entries
|
|
11
|
+
def initialize(result_infos:, result_count:)
|
|
12
|
+
@offsets = []
|
|
13
|
+
|
|
14
|
+
return if result_infos.null?
|
|
15
|
+
|
|
16
|
+
result_infos
|
|
17
|
+
.read_array_of_pointer(result_count)
|
|
18
|
+
.each { |result_info_ptr| validate!(result_info_ptr) }
|
|
19
|
+
.each do |result_info_ptr|
|
|
20
|
+
tp_ptr = Bindings.rd_kafka_ListOffsetsResultInfo_topic_partition(result_info_ptr)
|
|
21
|
+
tp = Bindings::TopicPartition.new(tp_ptr)
|
|
22
|
+
timestamp = Bindings.rd_kafka_ListOffsetsResultInfo_timestamp(result_info_ptr)
|
|
23
|
+
leader_epoch = Bindings.rd_kafka_topic_partition_get_leader_epoch(tp_ptr)
|
|
24
|
+
|
|
25
|
+
@offsets << {
|
|
26
|
+
topic: tp[:topic],
|
|
27
|
+
partition: tp[:partition],
|
|
28
|
+
offset: tp[:offset],
|
|
29
|
+
timestamp: timestamp,
|
|
30
|
+
leader_epoch: (leader_epoch == -1) ? nil : leader_epoch
|
|
31
|
+
}
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
# Validates the partition result and raises an error if invalid
|
|
38
|
+
# @param result_info_ptr [FFI::Pointer] pointer to the result info
|
|
39
|
+
# @raise [RdkafkaError] when the partition has an error
|
|
40
|
+
def validate!(result_info_ptr)
|
|
41
|
+
tp_ptr = Bindings.rd_kafka_ListOffsetsResultInfo_topic_partition(result_info_ptr)
|
|
42
|
+
tp = Bindings::TopicPartition.new(tp_ptr)
|
|
43
|
+
code = tp[:err]
|
|
44
|
+
|
|
45
|
+
return if code.zero?
|
|
46
|
+
|
|
47
|
+
raise RdkafkaError.new(code)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|