Class: Maxwell::Agent::WorkSchedule
- Inherits:
-
Object
- Object
- Maxwell::Agent::WorkSchedule
- Includes:
- Celluloid
- Defined in:
- lib/maxwell/agent/work_schedule.rb
Instance Method Summary collapse
- #add(work) ⇒ Object
- #all ⇒ Object
- #count ⇒ Object
- #get ⇒ Object
-
#initialize ⇒ WorkSchedule
constructor
A new instance of WorkSchedule.
- #put_back(work) ⇒ Object
- #schedule ⇒ Object
- #working ⇒ Object
Constructor Details
#initialize ⇒ WorkSchedule
Returns a new instance of WorkSchedule.
6 7 8 9 |
# File 'lib/maxwell/agent/work_schedule.rb', line 6 def initialize @schedule = RedisObjects::SortedSet.new_link('work_schedule') @working = RedisObjects::Set.new_link('work_schedule:working') end |
Instance Method Details
#add(work) ⇒ Object
11 12 13 14 |
# File 'lib/maxwell/agent/work_schedule.rb', line 11 def add(work) @schedule.async.add(work.generate_rank, work) work end |
#all ⇒ Object
37 38 39 |
# File 'lib/maxwell/agent/work_schedule.rb', line 37 def all schedule.concat(working) end |
#count ⇒ Object
16 17 18 |
# File 'lib/maxwell/agent/work_schedule.rb', line 16 def count schedule.count end |
#get ⇒ Object
20 21 22 |
# File 'lib/maxwell/agent/work_schedule.rb', line 20 def get find_ready_for_work end |
#put_back(work) ⇒ Object
24 25 26 27 |
# File 'lib/maxwell/agent/work_schedule.rb', line 24 def put_back(work) @working.async.remove(work) add(work) end |