Class: Qurd::Processor
- Inherits:
-
Object
- Object
- Qurd::Processor
- Includes:
- Mixins::AwsClients, Mixins::Configuration
- Defined in:
- lib/qurd/processor.rb
Overview
Use a Listener to act on an AWS SQS message
Instance Attribute Summary collapse
- #listener ⇒ Qurd::Listener readonly
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(listener, msg, listener_name, queue_url) ⇒ Processor
constructor
A new instance of Processor.
- #inspect ⇒ Object
-
#process ⇒ Object
Process an SQS message, by instantiating an instance of each action, calling
run_before
,run
, andrun_after
, and deleting the message.
Methods included from Mixins::AwsClients
Methods included from Mixins::Configuration
#qurd_config, #qurd_configuration, #qurd_logger, #qurd_logger!
Constructor Details
#initialize(listener, msg, listener_name, queue_url) ⇒ Processor
Returns a new instance of Processor.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/qurd/processor.rb', line 16 def initialize(listener, msg, listener_name, queue_url) @listener = listener @message = Message.new( message: msg, name: listener_name, queue_url: queue_url, aws_credentials: @listener.aws_credentials, region: @listener.region ) end |
Instance Attribute Details
#listener ⇒ Qurd::Listener (readonly)
12 13 14 |
# File 'lib/qurd/processor.rb', line 12 def listener @listener end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
12 |
# File 'lib/qurd/processor.rb', line 12 attr_reader :listener, :message |
Instance Method Details
#inspect ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/qurd/processor.rb', line 45 def inspect format('<Qurd::Processor:%x listener:%s message:%s>', object_id, listener.inspect, .inspect ) end |
#process ⇒ Object
Process an SQS message, by instantiating an instance of each action, calling run_before
, run
, and run_after
, and deleting the message.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/qurd/processor.rb', line 29 def process qurd_logger.info("Processing #{listener.name} " \ "action:#{.action} " \ "event:#{..Event}") if .action instantiate_actions run_before run_action run_after end .delete end |