Class: QueueFetcher
- Inherits:
-
Object
- Object
- QueueFetcher
- Defined in:
- lib/queue_fetcher.rb
Overview
Encapsulates the design decision about how to namespace SQS queues with environment-specific prefixes, as well as the dependency on the existence of a queueing interface. Typically this class only gets used at initialization time, a la this example from a Rails production.rb config file:
config.after_initialize do
interface = RightAws::SqsGen2.new(aws_access_key_id,aws_secret_access_key)
qf = QueueFetcher.new(interface,"production")
DatawarehouseLoader.queue = qf.fetch("datawarehouse_loader")
end
In tests, the queue interface could be set to a mock object
Instance Attribute Summary collapse
-
#queue_interface ⇒ Object
Returns the value of attribute queue_interface.
-
#queue_prefix ⇒ Object
Returns the value of attribute queue_prefix.
Instance Method Summary collapse
- #fetch(queue_name) ⇒ Object
-
#initialize(queue_interface, queue_prefix) ⇒ QueueFetcher
constructor
A new instance of QueueFetcher.
Constructor Details
#initialize(queue_interface, queue_prefix) ⇒ QueueFetcher
Returns a new instance of QueueFetcher.
18 19 20 21 |
# File 'lib/queue_fetcher.rb', line 18 def initialize(queue_interface,queue_prefix) @queue_interface = queue_interface @queue_prefix = queue_prefix end |
Instance Attribute Details
#queue_interface ⇒ Object
Returns the value of attribute queue_interface.
15 16 17 |
# File 'lib/queue_fetcher.rb', line 15 def queue_interface @queue_interface end |
#queue_prefix ⇒ Object
Returns the value of attribute queue_prefix.
16 17 18 |
# File 'lib/queue_fetcher.rb', line 16 def queue_prefix @queue_prefix end |
Instance Method Details
#fetch(queue_name) ⇒ Object
23 24 25 |
# File 'lib/queue_fetcher.rb', line 23 def fetch(queue_name) queue_interface.queue("#{queue_prefix}_#{queue_name}") end |