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- DEFAULT_PUBLISHER_POOL_SIZE =
32- DEFAULT_PUBLISHER_POOL_TIMEOUT =
2- DEFAULT_PUBLISHER_CONNECTION_ATTEMPTS =
30- DEFAULT_PUBLISHER_CONNECTION_BASE_DELAY =
1- DEFAULT_PUBLISHER_CONNECTION_BACKOFF_FACTOR =
1.5- DEFAULT_PUBLISHER_MAX_RETRIES =
3- DEFAULT_PUBLISHER_RETRY_BASE_DELAY =
0.1
- DEFAULT_PUBLISHER_RETRY_BACKOFF_FACTOR =
2- DEFAULT_PUBLISHER_CONFIRMS_POOL_SIZE =
32- DEFAULT_PUBLISHER_CONFIRMS_TIMEOUT =
5.0- DEFAULT_PUBLISHER_CONFIRMS_CLEANUP_TIMEOUT =
1.0
Instance Attribute Summary collapse
-
#connection_name ⇒ String
The name for the RabbitMQ connection.
-
#logger ⇒ Logger
The logger instance for Ears operations.
-
#publisher_confirms_cleanup_timeout ⇒ Float
The timeout in seconds for cleanup operations after confirmation timeout.
-
#publisher_confirms_pool_size ⇒ Integer
The size of the publisher confirms channel pool.
-
#publisher_confirms_timeout ⇒ Float
The timeout in seconds for waiting for publisher confirms.
-
#publisher_connection_attempts ⇒ Integer
The number of connection attempts for the publisher.
-
#publisher_connection_backoff_factor ⇒ Float
The backoff factor for exponential connection delays.
-
#publisher_connection_base_delay ⇒ Float
The base delay in seconds between connection attempts.
-
#publisher_max_retries ⇒ Integer
The maximum number of retries for failed publish attempts.
-
#publisher_pool_size ⇒ Integer
The size of the publisher channel pool.
-
#publisher_pool_timeout ⇒ Integer
The timeout in seconds for acquiring a channel from the publisher pool.
-
#publisher_retry_backoff_factor ⇒ Float
The backoff factor for exponential retry delays.
-
#publisher_retry_base_delay ⇒ Float
The base delay in seconds between retry attempts.
-
#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
rubocop:disable Metrics/MethodLength.
-
#recovery_attempts_exhausted ⇒ Proc
That is passed to Bunny’s recovery_attempts_exhausted block.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
rubocop:disable Metrics/MethodLength
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/ears/configuration.rb', line 72 def initialize # rubocop:disable Metrics/MethodLength @rabbitmq_url = DEFAULT_RABBITMQ_URL @recovery_attempts = DEFAULT_RECOVERY_ATTEMPTS @publisher_pool_size = DEFAULT_PUBLISHER_POOL_SIZE @publisher_pool_timeout = DEFAULT_PUBLISHER_POOL_TIMEOUT @publisher_connection_attempts = DEFAULT_PUBLISHER_CONNECTION_ATTEMPTS @publisher_connection_base_delay = DEFAULT_PUBLISHER_CONNECTION_BASE_DELAY @publisher_connection_backoff_factor = DEFAULT_PUBLISHER_CONNECTION_BACKOFF_FACTOR @publisher_max_retries = DEFAULT_PUBLISHER_MAX_RETRIES @publisher_retry_base_delay = DEFAULT_PUBLISHER_RETRY_BASE_DELAY @publisher_retry_backoff_factor = DEFAULT_PUBLISHER_RETRY_BACKOFF_FACTOR @publisher_confirms_pool_size = DEFAULT_PUBLISHER_CONFIRMS_POOL_SIZE @publisher_confirms_timeout = DEFAULT_PUBLISHER_CONFIRMS_TIMEOUT @publisher_confirms_cleanup_timeout = DEFAULT_PUBLISHER_CONFIRMS_CLEANUP_TIMEOUT @logger = Logger.new(IO::NULL) end |
Instance Attribute Details
#connection_name ⇒ String
Returns the name for the RabbitMQ connection.
28 29 30 |
# File 'lib/ears/configuration.rb', line 28 def connection_name @connection_name end |
#logger ⇒ Logger
Returns the logger instance for Ears operations.
61 62 63 |
# File 'lib/ears/configuration.rb', line 61 def logger @logger end |
#publisher_confirms_cleanup_timeout ⇒ Float
Returns the timeout in seconds for cleanup operations after confirmation timeout.
70 71 72 |
# File 'lib/ears/configuration.rb', line 70 def publisher_confirms_cleanup_timeout @publisher_confirms_cleanup_timeout end |
#publisher_confirms_pool_size ⇒ Integer
Returns the size of the publisher confirms channel pool.
64 65 66 |
# File 'lib/ears/configuration.rb', line 64 def publisher_confirms_pool_size @publisher_confirms_pool_size end |
#publisher_confirms_timeout ⇒ Float
Returns the timeout in seconds for waiting for publisher confirms.
67 68 69 |
# File 'lib/ears/configuration.rb', line 67 def publisher_confirms_timeout @publisher_confirms_timeout end |
#publisher_connection_attempts ⇒ Integer
Returns the number of connection attempts for the publisher.
43 44 45 |
# File 'lib/ears/configuration.rb', line 43 def publisher_connection_attempts @publisher_connection_attempts end |
#publisher_connection_backoff_factor ⇒ Float
Returns the backoff factor for exponential connection delays.
49 50 51 |
# File 'lib/ears/configuration.rb', line 49 def publisher_connection_backoff_factor @publisher_connection_backoff_factor end |
#publisher_connection_base_delay ⇒ Float
Returns the base delay in seconds between connection attempts.
46 47 48 |
# File 'lib/ears/configuration.rb', line 46 def publisher_connection_base_delay @publisher_connection_base_delay end |
#publisher_max_retries ⇒ Integer
Returns the maximum number of retries for failed publish attempts.
52 53 54 |
# File 'lib/ears/configuration.rb', line 52 def publisher_max_retries @publisher_max_retries end |
#publisher_pool_size ⇒ Integer
Returns the size of the publisher channel pool.
37 38 39 |
# File 'lib/ears/configuration.rb', line 37 def publisher_pool_size @publisher_pool_size end |
#publisher_pool_timeout ⇒ Integer
Returns the timeout in seconds for acquiring a channel from the publisher pool.
40 41 42 |
# File 'lib/ears/configuration.rb', line 40 def publisher_pool_timeout @publisher_pool_timeout end |
#publisher_retry_backoff_factor ⇒ Float
Returns the backoff factor for exponential retry delays.
58 59 60 |
# File 'lib/ears/configuration.rb', line 58 def publisher_retry_backoff_factor @publisher_retry_backoff_factor end |
#publisher_retry_base_delay ⇒ Float
Returns the base delay in seconds between retry attempts.
55 56 57 |
# File 'lib/ears/configuration.rb', line 55 def publisher_retry_base_delay @publisher_retry_base_delay end |
#rabbitmq_url ⇒ String
Returns the connection string for RabbitMQ.
25 26 27 |
# File 'lib/ears/configuration.rb', line 25 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.
31 32 33 |
# File 'lib/ears/configuration.rb', line 31 def recover_from_connection_close @recover_from_connection_close end |
#recovery_attempts ⇒ Integer
Returns max number of recovery attempts, nil means forever.
34 35 36 |
# File 'lib/ears/configuration.rb', line 34 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.
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/ears/configuration.rb', line 92 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
104 105 106 |
# File 'lib/ears/configuration.rb', line 104 def validate! raise ConnectionNameMissing unless connection_name end |