Class Scheduler

java.lang.Object
dev.relism.flash.ext.scheduler.Scheduler

public final class Scheduler extends Object
Runs background jobs on an interval or a cron expression.

 Scheduler jobs = ctx.require(Scheduler.class);

 jobs.every(Duration.ofMinutes(5), reports::refresh);
 jobs.cron("0 0 3 * * *", archive::sweep);
 

One platform thread keeps time; every job body runs on a virtual thread, so a slow job blocks nothing but itself.

Overlapping runs are skipped, always. Not an option — two copies of the same job running at once is a bug in every case anyone has needed so far, and a flag would only let it be configured wrongly. A skipped run is logged at WARN with how long the previous one has been going.

  • Method Details

    • every

      public void every(Duration interval, Runnable work)
      Runs work every interval, starting one interval from now.
    • every

      public void every(String name, Duration interval, Runnable work)
      Runs work every interval under an explicit name, used in logs.
    • cron

      public void cron(String expression, Runnable work)
      Runs work on a cron schedule. The expression is validated now, not at fire time.
    • cron

      public void cron(String name, String expression, Runnable work)
      Runs work on a cron schedule under an explicit name.
    • jobNames

      public List<String> jobNames()
      Job names in registration order — for a health or ops endpoint.