Class: Broker::Queue
Instance Attribute Summary collapse
-
#failed ⇒ Object
readonly
Returns the value of attribute failed.
-
#pending ⇒ Object
readonly
Returns the value of attribute pending.
-
#processed ⇒ Object
readonly
Returns the value of attribute processed.
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #failure(payload) ⇒ Object
-
#initialize ⇒ Queue
constructor
A new instance of Queue.
- #next ⇒ Object
- #push(paths) ⇒ Object
- #success(payload) ⇒ Object
Methods included from Utility
#safe_thread, #timestamp, #watcher
Constructor Details
#initialize ⇒ Queue
Returns a new instance of Queue.
10 11 12 13 14 |
# File 'lib/broker/queue.rb', line 10 def initialize @processed = 0 @pending = [] @failed = [] end |
Instance Attribute Details
#failed ⇒ Object (readonly)
Returns the value of attribute failed.
8 9 10 |
# File 'lib/broker/queue.rb', line 8 def failed @failed end |
#pending ⇒ Object (readonly)
Returns the value of attribute pending.
8 9 10 |
# File 'lib/broker/queue.rb', line 8 def pending @pending end |
#processed ⇒ Object (readonly)
Returns the value of attribute processed.
8 9 10 |
# File 'lib/broker/queue.rb', line 8 def processed @processed end |
Instance Method Details
#empty? ⇒ Boolean
24 25 26 |
# File 'lib/broker/queue.rb', line 24 def empty? @pending.empty? end |
#failure(payload) ⇒ Object
28 29 30 31 |
# File 'lib/broker/queue.rb', line 28 def failure(payload) @failed << payload move(payload, Broker.[:failed_path]) end |
#next ⇒ Object
20 21 22 |
# File 'lib/broker/queue.rb', line 20 def next @pending.pop end |
#push(paths) ⇒ Object
16 17 18 |
# File 'lib/broker/queue.rb', line 16 def push(paths) paths.each { |p| @pending << Broker::Payload.parse(p) } end |
#success(payload) ⇒ Object
33 34 35 36 |
# File 'lib/broker/queue.rb', line 33 def success(payload) @processed +=1 move(payload, Broker.[:processed_path]) end |