Class: Soda::Queue
Defined Under Namespace
Classes: Message
Constant Summary collapse
- DEFAULTS =
{ weight: 1, sleep: 1, wait: 1, timeout: 25, }
Constants included from Tools
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(name, url, options = {}) ⇒ Queue
constructor
A new instance of Queue.
-
#lazy_url ⇒ Object
Lazily fetch queue URL if one is not provided as part of the queue configuration.
- #pop ⇒ Object
- #push_in(interval, str) ⇒ Object
Methods included from Tools
#deep_symbolize_keys, #logger, #now, #sqs, #tid
Constructor Details
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
43 44 45 |
# File 'lib/soda/queue.rb', line 43 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
43 44 45 |
# File 'lib/soda/queue.rb', line 43 def @options end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
43 44 45 |
# File 'lib/soda/queue.rb', line 43 def url @url end |
Instance Method Details
#==(other) ⇒ Object
100 101 102 |
# File 'lib/soda/queue.rb', line 100 def ==(other) other.name == name end |
#lazy_url ⇒ Object
Lazily fetch queue URL if one is not provided as part of the queue configuration.
66 67 68 69 70 71 72 |
# File 'lib/soda/queue.rb', line 66 def lazy_url @lazy_url ||= url || begin resp = sqs.get_queue_url(queue_name: name) resp.queue_url end end |
#pop ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/soda/queue.rb', line 84 def pop resp = sqs.( queue_url: lazy_url, attribute_names: %w[All], message_attribute_names: %w[All], wait_time_seconds: wait, visibility_timeout: timeout, ) Enumerator.new do |yielder| resp..each do |msg| yielder.yield(Message.new(self, msg)) end end end |
#push_in(interval, str) ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/soda/queue.rb', line 74 def push_in(interval, str) sqs do |client| client.( queue_url: lazy_url, message_body: str, delay_seconds: interval, ) end end |