class VirtualDate::Scheduler

Overview

A simple, deterministic scheduler for VirtualDate vdates.

This scheduler:

Notes:

Defined in:

virtualdate.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(vdates : Array(VirtualDate) = [] of VirtualDate) #

[View source]

Instance Method Detail

def build(from : Time, to : Time) : Array(Scheduled) #

Produces scheduled vdates in [from, to).

Parameters:

  • granularity: how frequently to generate candidates from due rules (defaults to 1 minute)
  • max_candidates: safety limit to avoid infinite generation for very broad rules

Returns: Array(Scheduled), sorted by start time.


[View source]
def on_in_schedule?(scheduled_vdates : Array(Scheduled), vdate : VirtualDate, time : Time) : Bool #

True if vdate is considered “on” at time in the produced schedule.


[View source]
def schedule_candidate(candidate : Candidate, scheduled_vdates : Array(Scheduled), *, horizon : Time) : Scheduled | Nil #

Schedules a vdate, resolving conflicts by shifting forward (using vdate.shift when Time::Span), respecting vdate.fixed and max_shift/max_shifts.


[View source]
def vdates : Array(VirtualDate) #

[View source]
def vdates=(vdates : Array(VirtualDate)) #

[View source]