Sha256: 4f48e75fba4f161bea975b2becbdd1558354fadc8c5516ba0f092e3b8a67a935

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

module Rdkafka
  class Admin
    # A single config binding result that represents its values extracted from C
    class ConfigBindingResult
      attr_reader :name, :value, :read_only, :default, :sensitive, :synonym, :synonyms

      # @param config_ptr [FFI::Pointer] config pointer
      def initialize(config_ptr)
        @name = Bindings.rd_kafka_ConfigEntry_name(config_ptr)
        @value = Bindings.rd_kafka_ConfigEntry_value(config_ptr)
        @read_only = Bindings.rd_kafka_ConfigEntry_is_read_only(config_ptr)
        @default = Bindings.rd_kafka_ConfigEntry_is_default(config_ptr)
        @sensitive = Bindings.rd_kafka_ConfigEntry_is_sensitive(config_ptr)
        @synonym = Bindings.rd_kafka_ConfigEntry_is_synonym(config_ptr)
        @synonyms = []

        # The code below builds up the config synonyms using same config binding
        pointer_to_size_t = FFI::MemoryPointer.new(:int32)
        synonym_ptr = Bindings.rd_kafka_ConfigEntry_synonyms(config_ptr, pointer_to_size_t)
        synonyms_ptr = synonym_ptr.read_array_of_pointer(pointer_to_size_t.read_int)

        (1..pointer_to_size_t.read_int).map do |ar|
          self.class.new synonyms_ptr[ar - 1]
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rdkafka-0.19.0 lib/rdkafka/admin/config_binding_result.rb
rdkafka-0.18.0 lib/rdkafka/admin/config_binding_result.rb
rdkafka-0.17.0 lib/rdkafka/admin/config_binding_result.rb
rdkafka-0.16.1 lib/rdkafka/admin/config_binding_result.rb
rdkafka-0.16.0 lib/rdkafka/admin/config_binding_result.rb