Class: KafkaRest::Consumer

Inherits:
Object
  • Object
show all
Defined in:
lib/kafka_rest/consumer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, group_name) ⇒ Consumer

Returns a new instance of Consumer.



5
6
7
8
9
# File 'lib/kafka_rest/consumer.rb', line 5

def initialize(client, group_name)
  @client = client
  @group_name = group_name
  @instances = {}
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



3
4
5
# File 'lib/kafka_rest/consumer.rb', line 3

def client
  @client
end

#group_nameObject (readonly)

Returns the value of attribute group_name.



3
4
5
# File 'lib/kafka_rest/consumer.rb', line 3

def group_name
  @group_name
end

#instancesObject (readonly)

Returns the value of attribute instances.



3
4
5
# File 'lib/kafka_rest/consumer.rb', line 3

def instances
  @instances
end

Instance Method Details

#join {|instance| ... } ⇒ Object

Yields:

  • (instance)


11
12
13
14
15
16
17
# File 'lib/kafka_rest/consumer.rb', line 11

def join
  res = client.post(consumers_path)
  instance = ConsumerInstance.new(self, res)
  @instances[res['instance_id']] = instance
  yield instance if block_given?
  instance.start!
end