Class: Ears::Configuration
- Inherits:
-
Object
- Object
- Ears::Configuration
- Defined in:
- lib/ears/configuration.rb
Overview
The class representing the global Ears configuration.
Defined Under Namespace
Classes: ConnectionNameMissing
Constant Summary collapse
- DEFAULT_RABBITMQ_URL =
'amqp://guest:guest@localhost:5672'
- DEFAULT_RECOVERY_ATTEMPTS =
10
Instance Attribute Summary collapse
-
#connection_name ⇒ String
The name for the RabbitMQ connection.
-
#rabbitmq_url ⇒ String
The connection string for RabbitMQ.
-
#recover_from_connection_close ⇒ Boolean
If the recover_from_connection_close value is set for the RabbitMQ connection.
-
#recovery_attempts ⇒ Integer
Max number of recovery attempts, nil means forever.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#recovery_attempts_exhausted ⇒ Proc
That is passed to Bunny’s recovery_attempts_exhausted block.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
24 25 26 27 |
# File 'lib/ears/configuration.rb', line 24 def initialize @rabbitmq_url = DEFAULT_RABBITMQ_URL @recovery_attempts = DEFAULT_RECOVERY_ATTEMPTS end |
Instance Attribute Details
#connection_name ⇒ String
Returns the name for the RabbitMQ connection.
16 17 18 |
# File 'lib/ears/configuration.rb', line 16 def connection_name @connection_name end |
#rabbitmq_url ⇒ String
Returns the connection string for RabbitMQ.
13 14 15 |
# File 'lib/ears/configuration.rb', line 13 def rabbitmq_url @rabbitmq_url end |
#recover_from_connection_close ⇒ Boolean
Returns if the recover_from_connection_close value is set for the RabbitMQ connection.
19 20 21 |
# File 'lib/ears/configuration.rb', line 19 def recover_from_connection_close @recover_from_connection_close end |
#recovery_attempts ⇒ Integer
Returns max number of recovery attempts, nil means forever.
22 23 24 |
# File 'lib/ears/configuration.rb', line 22 def recovery_attempts @recovery_attempts end |
Instance Method Details
#recovery_attempts_exhausted ⇒ Proc
Returns that is passed to Bunny’s recovery_attempts_exhausted block. Nil if recovery_attempts is nil.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ears/configuration.rb', line 30 def recovery_attempts_exhausted return nil unless recovery_attempts Proc.new do # We need to have this since Bunny’s multi-threading is cumbersome here. # Session reconnection seems not to be done in the main thread. If we want to # achieve a restart of the app we need to modify the thread behaviour. Thread.current.abort_on_exception = true raise MaxRecoveryAttemptsExhaustedError end end |
#validate! ⇒ Object
42 43 44 |
# File 'lib/ears/configuration.rb', line 42 def validate! raise ConnectionNameMissing unless connection_name end |