forked from karafka/rdkafka-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backport incremental alter configs (karafka#448)
- Loading branch information
Showing
10 changed files
with
442 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
module Rdkafka | ||
class Admin | ||
class IncrementalAlterConfigsHandle < AbstractHandle | ||
layout :pending, :bool, | ||
:response, :int, | ||
:response_string, :pointer, | ||
:config_entries, :pointer, | ||
:entry_count, :int | ||
|
||
# @return [String] the name of the operation. | ||
def operation_name | ||
"incremental alter configs" | ||
end | ||
|
||
# @return [DescribeAclReport] instance with an array of acls that matches the request filters. | ||
def create_result | ||
IncrementalAlterConfigsReport.new( | ||
config_entries: self[:config_entries], | ||
entry_count: self[:entry_count] | ||
) | ||
end | ||
|
||
def raise_error | ||
raise RdkafkaError.new( | ||
self[:response], | ||
broker_message: self[:response_string].read_string | ||
) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# frozen_string_literal: true | ||
|
||
module Rdkafka | ||
class Admin | ||
class IncrementalAlterConfigsReport | ||
attr_reader :resources | ||
|
||
def initialize(config_entries:, entry_count:) | ||
@resources=[] | ||
|
||
return if config_entries == FFI::Pointer::NULL | ||
|
||
config_entries | ||
.read_array_of_pointer(entry_count) | ||
.each { |config_resource_result_ptr| validate!(config_resource_result_ptr) } | ||
.each do |config_resource_result_ptr| | ||
config_resource_result = ConfigResourceBindingResult.new(config_resource_result_ptr) | ||
|
||
pointer_to_size_t = FFI::MemoryPointer.new(:int32) | ||
configs_ptr = Bindings.rd_kafka_ConfigResource_configs( | ||
config_resource_result_ptr, | ||
pointer_to_size_t | ||
) | ||
|
||
configs_ptr | ||
.read_array_of_pointer(pointer_to_size_t.read_int) | ||
.map { |config_ptr| ConfigBindingResult.new(config_ptr) } | ||
.each { |config_binding| config_resource_result.configs << config_binding } | ||
|
||
@resources << config_resource_result | ||
end | ||
ensure | ||
return if config_entries == FFI::Pointer::NULL | ||
|
||
Bindings.rd_kafka_ConfigResource_destroy_array(config_entries, entry_count) | ||
end | ||
|
||
private | ||
|
||
def validate!(config_resource_result_ptr) | ||
code = Bindings.rd_kafka_ConfigResource_error(config_resource_result_ptr) | ||
|
||
return if code.zero? | ||
|
||
raise( | ||
RdkafkaError.new( | ||
code, | ||
Bindings.rd_kafka_ConfigResource_error_string(config_resource_result_ptr) | ||
) | ||
) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.