Class: Huck::Senders::SQSSender
- Inherits:
-
Huck::Sender
- Object
- Huck::Sender
- Huck::Senders::SQSSender
- Defined in:
- lib/huck/senders/sqs.rb
Overview
A sender that talks to Amazon Simple Queue Service
Instance Attribute Summary
Attributes inherited from Huck::Sender
Instance Method Summary collapse
-
#initialize ⇒ SQSSender
constructor
Includes all required modules for the SQS sender.
-
#send(msg) ⇒ Object
Send an arbitrary text message to the queue for processing.
-
#verify_config ⇒ Object
Ensures that configuration is set properly before trying to use the connection data to talk to AWS.
Methods inherited from Huck::Sender
Constructor Details
Instance Method Details
#send(msg) ⇒ Object
Send an arbitrary text message to the queue for processing
Parameters:
- msg
-
The message to process
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/huck/senders/sqs.rb', line 33 def send msg verify_config sqs = AWS::SQS.new( :access_key_id => @config['sqs']['access_key_id'], :secret_access_key => @config['sqs']['secret_access_key'], :region => @config['sqs']['region'] ) queue = sqs.queues.create @config['sqs']['queue_name'] queue. msg end |
#verify_config ⇒ Object
Ensures that configuration is set properly before trying to use the connection data to talk to AWS
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/huck/senders/sqs.rb', line 15 def verify_config if !@config.has_key? 'sqs' raise RuntimeError, 'missing sqs sender config' end ['access_key_id', 'secret_access_key', 'region', 'queue_name'].each do |key| if !@config['sqs'].has_key? key raise RuntimeError, "missing sqs sender config: #{key}" end end end |