Skip to main content

Scheduling

Context

Scheduling entities

  • Scheduling of experiment on project level
  • Scheduling of experiment on user level

Scheduling types

  • Periodic fix time (each day/week/month/year etc.). What is a month exactly? -> Crontab like
  • Interval schedule experiment certain time after trigger (e.g. experiment completed, certain experiment results, ...)
  • Agenda schedules. Fixed time, one-off

Schedulable entities -> jobs

  • Experiments
  • Notifications

Scheduled item

  • Expiration time: After a certain time the scheduled item should not be available anymore.
    • Duration (startTime and endTime)
    • Event (e.g. expiry after end of day, expire for some other reason?)
  • What to do after expiry?
    • Reschedule with original interval
    • Skip (for periodic schedule, next item scheduled as usual)
  • Maximum occurences

Events

What kind of event should be able to trigger/influence the scheduling?

  • Experiment completed
  • Job expiry
  • A date(time). Can we do this recursively by scheduling the event?

User

  • Get all (future) scheduled experiments

Architecture

Schedules are stored on Project enities (:material-database:tenant) and User entities (:material-database:user). Explicitly scheduled experiments (e.g. an experiment schedules x minutes after some event like experiment completion) should be store on the User entity (:material-database:user).

On each change of a schedule an Event should be sent with the new schedule. The scheduling-service should subscribe to these events and create a new internal schedule.

The front-end (Orikami App) is responsible to show the correct experiments in the today screen based on the schedule and the explicitly scheduled experiments. The schedule should be fetched periodically (every 15 minutes), immediately after an scheduled experiment notification has been received (see React Native Notifications) and when refreshing the today screen (pull down).

Resources:

https://www.npmjs.com/package/node-schedule

"Node Schedule API Example"

Handle Jobs and Job Invocations There are some function to get information for a Job and to handle the Job and Invocations.

job.cancel(reschedule)
You can invalidate any job with the cancel() method:

All planned invocations will be canceled. When you set the parameter reschedule to true then the Job is newly scheduled afterwards.

job.cancelNext(reschedule)
This method invalidates the next planned invocation or the job. When you set the parameter reschedule to true then the Job is newly scheduled afterwards.

job.reschedule(spec)
This method cancels all pending invocation and registers the Job completely new again using the given specification. Return true/false on success/failure.

job.nextInvocation()
This method returns a Date object for the planned next Invocation for this Job. If no invocation is planned the method returns null.