Class: Ronin::Recon::ValueStatus
- Inherits:
-
Object
- Object
- Ronin::Recon::ValueStatus
- Defined in:
- lib/ronin/recon/value_status.rb
Overview
Represents the status of every value across all queues and workers.
Instance Attribute Summary collapse
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Determines if there are no more values within the queue or being processed by any of the workers.
-
#initialize ⇒ ValueStatus
constructor
A new instance of ValueStatus.
-
#job_completed(worker_class, value) ⇒ Object
(also: #job_failed)
Records that a worker has completed processing the value.
-
#job_started(worker_class, value) ⇒ Object
Records that a worker has dequeued the value and started processing it.
-
#value_enqueued(worker_class, value) ⇒ Object
Records that a value was enqueued for the given worker class.
Constructor Details
#initialize ⇒ ValueStatus
Returns a new instance of ValueStatus.
30 31 32 |
# File 'lib/ronin/recon/value_status.rb', line 30 def initialize @values = {} end |
Instance Attribute Details
#values ⇒ Object (readonly)
Returns the value of attribute values.
28 29 30 |
# File 'lib/ronin/recon/value_status.rb', line 28 def values @values end |
Instance Method Details
#empty? ⇒ Boolean
Determines if there are no more values within the queue or being processed by any of the workers.
81 82 83 |
# File 'lib/ronin/recon/value_status.rb', line 81 def empty? @values.empty? end |
#job_completed(worker_class, value) ⇒ Object Also known as: job_failed
Records that a worker has completed processing the value.
63 64 65 66 67 68 69 70 71 |
# File 'lib/ronin/recon/value_status.rb', line 63 def job_completed(worker_class,value) if (worker_statuses = @values[value]) worker_statuses.delete(worker_class) if worker_statuses.empty? @values.delete(value) end end end |
#job_started(worker_class, value) ⇒ Object
Records that a worker has dequeued the value and started processing it.
52 53 54 |
# File 'lib/ronin/recon/value_status.rb', line 52 def job_started(worker_class,value) (@values[value] ||= {})[worker_class] = :working end |
#value_enqueued(worker_class, value) ⇒ Object
Records that a value was enqueued for the given worker class.
41 42 43 |
# File 'lib/ronin/recon/value_status.rb', line 41 def value_enqueued(worker_class,value) (@values[value] ||= {})[worker_class] = :enqueued end |