Class: Khronos::Server::Controller
- Inherits:
-
Object
- Object
- Khronos::Server::Controller
- Defined in:
- lib/khronos/server/controller.rb
Instance Attribute Summary collapse
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
- #check_schedule! ⇒ Object
-
#initialize(runner = nil) ⇒ Controller
constructor
A new instance of Controller.
- #logger=(logger) ⇒ Object
- #start! ⇒ Object
Constructor Details
#initialize(runner = nil) ⇒ Controller
Returns a new instance of Controller.
6 7 8 9 |
# File 'lib/khronos/server/controller.rb', line 6 def initialize(runner=nil) @storage = Storage.new @runner = runner end |
Instance Attribute Details
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
4 5 6 |
# File 'lib/khronos/server/controller.rb', line 4 def storage @storage end |
Instance Method Details
#check_schedule! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/khronos/server/controller.rb', line 15 def check_schedule! puts "Checking... #{Time.now}" count = 0 Storage::Schedule.fetch(Time.now).each do |schedule| @runner.enqueue(schedule) count += 1 end puts "Tick. #{count} jobs to run." end |
#logger=(logger) ⇒ Object
11 12 13 |
# File 'lib/khronos/server/controller.rb', line 11 def logger=(logger) puts "WARNING: Not implemented yet." end |
#start! ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/khronos/server/controller.rb', line 27 def start! loop do check_schedule! # # Sleep 'interval' seconds # sleep(Config.instance.controller['interval']) end end |