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
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/huck/senders/sqs.rb', line 32 def send msg verify_config = Hash.new [:access_key_id, :secret_access_key, :region].each do |arg| if @config['sqs'].has_key? arg.to_s [arg] = @config['sqs'][arg.to_s] end end sqs = AWS::SQS.new 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. It is possible that IAM profiles are in use, so we can’t strictly require that all of the access information is set in the configuration.
17 18 19 20 21 22 23 24 |
# File 'lib/huck/senders/sqs.rb', line 17 def verify_config if !@config.has_key? 'sqs' raise Huck::Error, 'missing sqs sender config' end if !@config['sqs'].has_key? 'queue_name' raise Huck::Error, 'missing sqs sender config: queue_name' end end |