Class: Kronos::Runner::Synchronous

Inherits:
Object
  • Object
show all
Defined in:
lib/kronos/runner/synchronous.rb,
lib/kronos/runner/synchronous/lock_manager.rb

Direct Known Subclasses

Asynchronous

Defined Under Namespace

Classes: LockManager

Constant Summary collapse

METADATA_COLLECTORS =

TODO: Let consumer configure it

[
  lambda do |block|
    start = Time.now
    result = block.call
    finish = Time.now

    { **result, start: start.to_s, finish: finish.to_s, duration: (finish - start).to_s }
  end
].freeze
ID_FUNC =
lambda do |block|
  lambda do
    block.call
    {}
  end
end

Instance Method Summary collapse

Constructor Details

#initialize(tasks, dependencies) ⇒ Synchronous

Returns a new instance of Synchronous.



24
25
26
27
28
# File 'lib/kronos/runner/synchronous.rb', line 24

def initialize(tasks, dependencies)
  @tasks = tasks
  @dependencies = dependencies
  @lock_manager = LockManager.new(dependencies.storage)
end

Instance Method Details

#startObject



30
31
32
33
34
35
36
37
38
# File 'lib/kronos/runner/synchronous.rb', line 30

def start
  loop do
    run_resolved_tasks
    schedule_current_tasks

    # TODO: Configurable sleep between runs
    sleep(1)
  end
end