Class: Harmoniser::Topology
- Inherits:
-
Object
- Object
- Harmoniser::Topology
- Includes:
- Connectable
- Defined in:
- lib/harmoniser/topology.rb
Constant Summary
Constants included from Connectable
Instance Attribute Summary collapse
-
#bindings ⇒ Object
readonly
Returns the value of attribute bindings.
-
#exchanges ⇒ Object
readonly
Returns the value of attribute exchanges.
-
#queues ⇒ Object
readonly
Returns the value of attribute queues.
Instance Method Summary collapse
- #add_binding(exchange_name, destination_name, destination_type = :queue, **opts) ⇒ Object
- #add_exchange(type, name, **opts) ⇒ Object
- #add_queue(name, **opts) ⇒ Object
- #declare ⇒ Object
-
#initialize ⇒ Topology
constructor
A new instance of Topology.
Methods included from Connectable
Constructor Details
#initialize ⇒ Topology
Returns a new instance of Topology.
10 11 12 13 14 |
# File 'lib/harmoniser/topology.rb', line 10 def initialize @bindings = Set.new @exchanges = Set.new @queues = Set.new end |
Instance Attribute Details
#bindings ⇒ Object (readonly)
Returns the value of attribute bindings.
8 9 10 |
# File 'lib/harmoniser/topology.rb', line 8 def bindings @bindings end |
#exchanges ⇒ Object (readonly)
Returns the value of attribute exchanges.
8 9 10 |
# File 'lib/harmoniser/topology.rb', line 8 def exchanges @exchanges end |
#queues ⇒ Object (readonly)
Returns the value of attribute queues.
8 9 10 |
# File 'lib/harmoniser/topology.rb', line 8 def queues @queues end |
Instance Method Details
#add_binding(exchange_name, destination_name, destination_type = :queue, **opts) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/harmoniser/topology.rb', line 33 def add_binding(exchange_name, destination_name, destination_type = :queue, **opts) @bindings << Definition::Binding.new( exchange_name: exchange_name, destination_name: destination_name, destination_type: destination_type, opts: opts ) self end |
#add_exchange(type, name, **opts) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/harmoniser/topology.rb', line 16 def add_exchange(type, name, **opts) @exchanges << Definition::Exchange.new( type: type, name: name, opts: opts ) self end |
#add_queue(name, **opts) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/harmoniser/topology.rb', line 25 def add_queue(name, **opts) @queues << Definition::Queue.new( name: name, opts: opts ) self end |
#declare ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/harmoniser/topology.rb', line 43 def declare self.class.create_channel.tap do |ch| declare_exchanges(ch) declare_queues(ch) declare_bindings(ch) ch.connection.close end end |