Class: QProcessor::SQSSource
- Inherits:
-
Object
- Object
- QProcessor::SQSSource
- Defined in:
- lib/qprocessor/sqs_source.rb
Constant Summary collapse
- MAX_MESSAGE_WAIT =
A constant for the maximum wait for message timeout to be used by the source.
3
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#get {|message| ... } ⇒ Object
This method blocks until a job is available, at which points it is returned.
-
#initialize ⇒ SQSSource
constructor
A new instance of SQSSource.
Constructor Details
#initialize ⇒ SQSSource
Returns a new instance of SQSSource.
12 13 14 |
# File 'lib/qprocessor/sqs_source.rb', line 12 def initialize @name = "SQS Source" end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
15 16 17 |
# File 'lib/qprocessor/sqs_source.rb', line 15 def name @name end |
Instance Method Details
#get {|message| ... } ⇒ Object
This method blocks until a job is available, at which points it is returned.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/qprocessor/sqs_source.rb', line 19 def get = nil client = sqs_client url = sqs_queue_url(sqs_queue_name) while .nil? result = client.(max_number_of_messages: 1, queue_url: url, wait_time_seconds: MAX_MESSAGE_WAIT) = QProcessor::SQSMessage.new(result.[0], client, url) if !result..empty? end yield if block_given? end |