Class: Rdkafka::Callbacks::TopicResult

Inherits:
Object
  • Object
show all
Defined in:
lib/rdkafka/callbacks.rb

Overview

Extracts attributes of a rd_kafka_topic_result_t

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(topic_result_pointer) ⇒ TopicResult

Returns a new instance of TopicResult.

Parameters:

  • topic_result_pointer (FFI::Pointer)

    pointer to the topic result struct



14
15
16
17
18
# File 'lib/rdkafka/callbacks.rb', line 14

def initialize(topic_result_pointer)
  @result_error = Rdkafka::Bindings.rd_kafka_topic_result_error(topic_result_pointer)
  @error_string = Rdkafka::Bindings.rd_kafka_topic_result_error_string(topic_result_pointer)
  @result_name = Rdkafka::Bindings.rd_kafka_topic_result_name(topic_result_pointer)
end

Instance Attribute Details

#error_stringObject (readonly)

Returns the value of attribute error_string.



11
12
13
# File 'lib/rdkafka/callbacks.rb', line 11

def error_string
  @error_string
end

#result_errorObject (readonly)

Returns the value of attribute result_error.



11
12
13
# File 'lib/rdkafka/callbacks.rb', line 11

def result_error
  @result_error
end

#result_nameObject (readonly)

Returns the value of attribute result_name.



11
12
13
# File 'lib/rdkafka/callbacks.rb', line 11

def result_name
  @result_name
end

Class Method Details

.create_topic_results_from_array(count, array_pointer) ⇒ Array<TopicResult>

Returns array of topic results.

Parameters:

  • count (Integer)

    number of results

  • array_pointer (FFI::Pointer)

    pointer to the results array

Returns:



23
24
25
26
27
28
# File 'lib/rdkafka/callbacks.rb', line 23

def self.create_topic_results_from_array(count, array_pointer)
  (1..count).map do |index|
    result_pointer = (array_pointer + (index - 1)).read_pointer
    new(result_pointer)
  end
end