Class: Surfliner::Mq::QueueConfig
- Inherits:
-
Object
- Object
- Surfliner::Mq::QueueConfig
- Defined in:
- lib/surfliner/mq/queue_config.rb
Overview
Encapsulates queue configuration
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The queue to listen to.
-
#options ⇒ Hash
readonly
RabbitMQ queue options.
Class Method Summary collapse
-
.from_env(**options) ⇒ QueueConfig
Returns a default (environment-variable-based) configuration with the specified options.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Whether
otherrepresents the same configuration as this object. -
#eql?(other) ⇒ Boolean
Whether
otherrepresents the same configuration as this object. -
#hash ⇒ Integer
The hash value of this object.
-
#initialize(name:, options: {}) ⇒ QueueConfig
constructor
A new instance of QueueConfig.
Constructor Details
#initialize(name:, options: {}) ⇒ QueueConfig
Returns a new instance of QueueConfig.
13 14 15 16 |
# File 'lib/surfliner/mq/queue_config.rb', line 13 def initialize(name:, options: {}) @name = name @options = end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns The queue to listen to.
6 7 8 |
# File 'lib/surfliner/mq/queue_config.rb', line 6 def name @name end |
#options ⇒ Hash (readonly)
Returns RabbitMQ queue options. (See Bunny::Channel#queue).
9 10 11 |
# File 'lib/surfliner/mq/queue_config.rb', line 9 def @options end |
Class Method Details
.from_env(**options) ⇒ QueueConfig
Returns a default (environment-variable-based) configuration with the specified options.
| Variable | Sample value | Description |
|---|---|---|
RABBITMQ_QUEUE |
surfliner.metadata |
RabbitMQ queue name |
52 53 54 55 56 57 |
# File 'lib/surfliner/mq/queue_config.rb', line 52 def from_env(**) QueueConfig.new( name: ENV.fetch("RABBITMQ_QUEUE"), options: ) end |
Instance Method Details
#==(other) ⇒ Boolean
Whether other represents the same configuration as this object.
Note that if name or options are modified, equality becomes unstable.
30 31 32 33 |
# File 'lib/surfliner/mq/queue_config.rb', line 30 def ==(other) return unless other.class == self.class other.name == name && other. == end |
#eql?(other) ⇒ Boolean
Whether other represents the same configuration as this object.
Note that if name or options are modified, equality becomes unstable.
22 23 24 |
# File 'lib/surfliner/mq/queue_config.rb', line 22 def eql?(other) self == other end |
#hash ⇒ Integer
The hash value of this object. Equal configurations will have equal hash values.
Note that if name or options are modified, the hash value becomes unstable.
38 39 40 |
# File 'lib/surfliner/mq/queue_config.rb', line 38 def hash [name, ].hash end |