Module: Protege::Loop

Extended by:
Loop
Included in:
Loop
Defined in:
lib/protege/loop.rb,
lib/protege/loop/schedule.rb,
lib/protege/loop/scheduler.rb

Overview

LOGI "L" — the loop layer. Owns scheduled, proactive work: deciding which responsibilities are due on each clock tick and dispatching their runs. The Scheduler drives dispatch and Schedule parses and evaluates cron expressions.

Class methods on this module are the cross-namespace entry points. Callers (the recurring tick job, the Responsibility model) use these rather than reaching into Scheduler / Schedule directly.

Defined Under Namespace

Classes: Schedule, Scheduler

Instance Method Summary collapse

Instance Method Details

#dispatchvoid

This method returns an undefined value.

Dispatch a run for every responsibility due right now. Called once per clock tick.



16
17
18
# File 'lib/protege/loop.rb', line 16

def dispatch
  Scheduler.dispatch
end

#schedule_due?(expression, at:) ⇒ Boolean

Report whether a cron expression is due at a given time.

Parameters:

  • expression (String)

    the cron expression

  • at (Time)

    the moment to test

Returns:

  • (Boolean)

    true when due at at



33
34
35
# File 'lib/protege/loop.rb', line 33

def schedule_due?(expression, at:)
  Schedule.new(expression).due?(at)
end

#schedule_valid?(expression) ⇒ Boolean

Report whether a cron expression is well-formed — for model validation.

Parameters:

  • expression (String)

    the cron expression

Returns:

  • (Boolean)

    true when parseable



24
25
26
# File 'lib/protege/loop.rb', line 24

def schedule_valid?(expression)
  Schedule.valid?(expression)
end