Class: Hermann::Discovery::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/hermann/discovery/metadata.rb

Defined Under Namespace

Classes: Broker, Partition, Topic

Constant Summary collapse

DEFAULT_TIMEOUT_MS =
2_000

Instance Method Summary collapse

Constructor Details

#initialize(brokers, options = {}) ⇒ Metadata

Returns a new instance of Metadata.



21
22
23
24
25
# File 'lib/hermann/discovery/metadata.rb', line 21

def initialize(brokers, options = {})
  raise "this is an MRI api only!" if Hermann.jruby?
  @internal = Hermann::Provider::RDKafka::Producer.new(brokers)
  @timeout = options[:timeout] || DEFAULT_TIMEOUT_MS
end

Instance Method Details

#brokersObject

=> [{:id=>3, :host=>“kafka3.alpha4.sac1.zdsys.com”, :port=>9092],

:topics  => {"testtopic"=>[{:id=>0, :leader_id=>3, :replica_ids=>[3, 1],  :isr_ids=>[3, 1]}}}


32
33
34
# File 'lib/hermann/discovery/metadata.rb', line 32

def brokers
  (@internal.(nil, @timeout))
end

#topic(t) ⇒ Object



36
37
38
# File 'lib/hermann/discovery/metadata.rb', line 36

def topic(t)
  get_topics(t)[t]
end

#topicsObject



40
41
42
# File 'lib/hermann/discovery/metadata.rb', line 40

def topics
  get_topics
end