Timers

Timers provide a mechanism where a ClearBlade code service can be scheduled to execute at certain time intervals. Timers are similar to Unix cron jobs, with a simpler scheduling mechanism.

The key pieces of a timer are it’s name, description, associated code service, and schedule. The schedule determines when the code service is executed. The name of a timer must be unique within a system/application. The description is optional.

Schedules

A schedule consists of three parts:

  1. Start date: This defines the date in which the timer should become effective.
  2. Start time: This defines the time, on the specified Start Date, in which the timer should become effective.
  3. Repeats: This specifies how many times the timer should repeat after the first execution. 0 (zero) means run only once. -1 means run forever.
  4. Frequency: This specifies the time interval between runs of the associated code service. Frequency can be expressed in terms of seconds, minutes, hours, days, or weeks.

With these simple schedule parameters, You can specify schedules such as

  • Run forever every five minutes starting now
  • Run 26 times every two weeks starting Friday, December 25th, 2015
  • Run once at midnight

Execution Context

Unlike services that are called by clients and execute with the user privledges the default user context for the timer is the developer who initially created the timer. Unless the associated code service specifies a “Run as” other than “caller”, the timer will always run as the developer who created the timer.

Secondly, other than the standard parameters that ClearBlade passes to code services, no parameters are passed to timers.