Class: Lapine::Consumer::Topology

Inherits:
Struct
  • Object
show all
Defined in:
lib/lapine/consumer/topology.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject

Returns the value of attribute config

Returns:

  • (Object)

    the current value of config



5
6
7
# File 'lib/lapine/consumer/topology.rb', line 5

def config
  @config
end

#loggerObject

Returns the value of attribute logger

Returns:

  • (Object)

    the current value of logger



5
6
7
# File 'lib/lapine/consumer/topology.rb', line 5

def logger
  @logger
end

Instance Method Details

#close!Object



26
27
28
29
30
31
# File 'lib/lapine/consumer/topology.rb', line 26

def close!
  return unless @cons
  @cons.values.each do |conn|
    conn.close!
  end
end

#each_bindingObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/lapine/consumer/topology.rb', line 7

def each_binding
  config.queues.each do |node|
    classes = node['handlers'].map do |handler|
      handler.split('::').inject(Object) do |const, name|
        const.const_get(name)
      end
    end

    yield node['q'], get_conn(node['topic']), node['routing_key'], classes
  end
end

#each_topicObject



20
21
22
23
24
# File 'lib/lapine/consumer/topology.rb', line 20

def each_topic
  config.topics.each do |topic|
    yield topic
  end
end