Class: Maxwell::Agent::WorkSchedule

Inherits:
Object
  • Object
show all
Includes:
Celluloid
Defined in:
lib/maxwell/agent/work_schedule.rb

Instance Method Summary collapse

Constructor Details

#initializeWorkSchedule

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

#allObject



37
38
39
# File 'lib/maxwell/agent/work_schedule.rb', line 37

def all
  schedule.concat(working)
end

#countObject



16
17
18
# File 'lib/maxwell/agent/work_schedule.rb', line 16

def count
  schedule.count
end

#getObject



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

#scheduleObject



33
34
35
# File 'lib/maxwell/agent/work_schedule.rb', line 33

def schedule
  @schedule.all.map {|work| Work.load(work) }
end

#workingObject



29
30
31
# File 'lib/maxwell/agent/work_schedule.rb', line 29

def working
  @working.all.map {|work| Work.load(work) }
end