Sha256: 2c031ac67805c234b17c7f7eee55e06d9b1525d8613dd5d4fdac9313376894f6

Contents?: true

Size: 763 Bytes

Versions: 7

Compression:

Stored size: 763 Bytes

Contents

module Khronos
  module Server
    class Controller
      attr_reader :storage

      def initialize(runner=nil)
        @storage = Storage.new
        @runner = runner
      end

      def logger=(logger)
        puts "WARNING: Not implemented yet."
      end

      def check_schedule!
        puts "Checking... #{Time.now}"
        count = 0
        Khronos::Scheduler.fetch(Time.now).each do |schedule|
          Khronos::Scheduler.run(schedule, @runner)
          count += 1
        end
        puts "Tick. #{count} jobs to run."
      end

      def start!
        loop do
          check_schedule!

          #
          # Sleep 'interval' seconds
          #
          sleep(Config.instance.controller['interval'])
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
khronos-0.1.3 lib/khronos/server/controller.rb
khronos-0.1.2 lib/khronos/server/controller.rb
khronos-0.1.1 lib/khronos/server/controller.rb
khronos-0.1.0 lib/khronos/server/controller.rb
khronos-0.0.3.pre4 lib/khronos/server/controller.rb
khronos-0.0.3.pre3 lib/khronos/server/controller.rb
khronos-0.0.3.pre2 lib/khronos/server/controller.rb