Class: RubyRabbitmqJanus::Janus::Transaction
- Inherits:
-
Object
- Object
- RubyRabbitmqJanus::Janus::Transaction
- Defined in:
- lib/rrj/janus/transactions/transaction.rb
Overview
This class work with janus and send a series of message :reek:TooManyInstanceVariables
Direct Known Subclasses
Instance Attribute Summary collapse
-
#handle ⇒ Object
readonly
private
Returns the value of attribute handle.
-
#publish ⇒ Object
readonly
private
Returns the value of attribute publish.
-
#rabbit ⇒ Object
readonly
private
Returns the value of attribute rabbit.
-
#response ⇒ Object
readonly
private
Returns the value of attribute response.
-
#session ⇒ Object
readonly
private
Returns the value of attribute session.
Instance Method Summary collapse
-
#choose_queue(exclusive = false) ⇒ Object
private
determine queue used :reek:ControlParameter and :reek:BooleanParameter.
-
#connect(exclusive) ⇒ Object
Opening a short transaction with rabbitmq and close when is ending.
-
#create_handle ⇒ Object
private
Associate handle to transaction.
-
#initialize(session) ⇒ Transaction
constructor
Initialize an transaction.
-
#send_a_message ⇒ Object
private
Send a message to queue.
Constructor Details
#initialize(session) ⇒ Transaction
Initialize an transaction
10 11 12 13 14 15 16 |
# File 'lib/rrj/janus/transactions/transaction.rb', line 10 def initialize(session) @rabbit = Rabbit::Connect.new @session = session @response = @handle = @publish = nil rescue => error raise Errors::JanusTransaction, error end |
Instance Attribute Details
#handle ⇒ Object (readonly, private)
Returns the value of attribute handle.
28 29 30 |
# File 'lib/rrj/janus/transactions/transaction.rb', line 28 def handle @handle end |
#publish ⇒ Object (readonly, private)
Returns the value of attribute publish.
28 29 30 |
# File 'lib/rrj/janus/transactions/transaction.rb', line 28 def publish @publish end |
#rabbit ⇒ Object (readonly, private)
Returns the value of attribute rabbit.
28 29 30 |
# File 'lib/rrj/janus/transactions/transaction.rb', line 28 def rabbit @rabbit end |
#response ⇒ Object (readonly, private)
Returns the value of attribute response.
28 29 30 |
# File 'lib/rrj/janus/transactions/transaction.rb', line 28 def response @response end |
#session ⇒ Object (readonly, private)
Returns the value of attribute session.
28 29 30 |
# File 'lib/rrj/janus/transactions/transaction.rb', line 28 def session @session end |
Instance Method Details
#choose_queue(exclusive = false) ⇒ Object (private)
determine queue used :reek:ControlParameter and :reek:BooleanParameter
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rrj/janus/transactions/transaction.rb', line 32 def choose_queue(exclusive = false) chan = @rabbit.channel @publish = if exclusive Tools::Log.instance.debug 'Choose an queue non Exclusive : to-janus' Rabbit::Publisher::PublishNonExclusive.new(chan) else Tools::Log.instance.debug 'Choose an queue Exclusive : ampq.gen-xxx' Rabbit::Publisher::PublishExclusive.new(chan, '') end end |
#connect(exclusive) ⇒ Object
Opening a short transaction with rabbitmq and close when is ending
19 20 21 22 23 24 |
# File 'lib/rrj/janus/transactions/transaction.rb', line 19 def connect(exclusive) @rabbit.transaction_short do choose_queue(exclusive) { yield } end end |