Class: PikaQ::Publisher
- Inherits:
-
Object
- Object
- PikaQ::Publisher
- Defined in:
- lib/pika_q/publisher.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#exchange ⇒ Object
readonly
Returns the value of attribute exchange.
-
#exchange_name ⇒ Object
readonly
Returns the value of attribute exchange_name.
-
#exchange_options ⇒ Object
readonly
Returns the value of attribute exchange_options.
-
#exchange_type ⇒ Object
readonly
Returns the value of attribute exchange_type.
Instance Method Summary collapse
- #close_channel ⇒ Object
-
#initialize(channel, exchange_name, exchange_type = :default, exchange_options = { durable: false, auto_delete: false }) ⇒ Publisher
constructor
A new instance of Publisher.
- #send_message(payload, message_options = {}) ⇒ Object
Constructor Details
#initialize(channel, exchange_name, exchange_type = :default, exchange_options = { durable: false, auto_delete: false }) ⇒ Publisher
Returns a new instance of Publisher.
9 10 11 12 13 14 15 |
# File 'lib/pika_q/publisher.rb', line 9 def initialize(channel, exchange_name, exchange_type = :default, = { durable: false, auto_delete: false }) @channel = channel @exchange_name = exchange_name @exchange_type = exchange_type @exchange_options = @exchange = connect_to_exchange end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
7 8 9 |
# File 'lib/pika_q/publisher.rb', line 7 def channel @channel end |
#exchange ⇒ Object (readonly)
Returns the value of attribute exchange.
7 8 9 |
# File 'lib/pika_q/publisher.rb', line 7 def exchange @exchange end |
#exchange_name ⇒ Object (readonly)
Returns the value of attribute exchange_name.
7 8 9 |
# File 'lib/pika_q/publisher.rb', line 7 def exchange_name @exchange_name end |
#exchange_options ⇒ Object (readonly)
Returns the value of attribute exchange_options.
7 8 9 |
# File 'lib/pika_q/publisher.rb', line 7 def @exchange_options end |
#exchange_type ⇒ Object (readonly)
Returns the value of attribute exchange_type.
7 8 9 |
# File 'lib/pika_q/publisher.rb', line 7 def exchange_type @exchange_type end |
Instance Method Details
#close_channel ⇒ Object
24 25 26 |
# File 'lib/pika_q/publisher.rb', line 24 def close_channel channel.close end |
#send_message(payload, message_options = {}) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/pika_q/publisher.rb', line 17 def (payload, = {}) ||= {} = .merge() published = exchange.publish(payload, ) published end |