shakespeare/actors/scheduled

An actor that runs on a schedule.

Types

A schedule for a ScheduledActor.

pub type Schedule {
  Hourly(minute: Int, second: Int)
  Daily(hour: Int, minute: Int, second: Int)
  Weekly(day: Weekday, hour: Int, minute: Int, second: Int)
}

Constructors

  • Hourly(minute: Int, second: Int)

    The actor runs hourly, at the specified minute and second.

  • Daily(hour: Int, minute: Int, second: Int)

    The actor runs daily, at the specified hour, minute, and second.

  • Weekly(day: Weekday, hour: Int, minute: Int, second: Int)

    The actor runs weekly, at the specified day, hour, minute, and second.

An actor that performs a given action on a schedule.

pub opaque type ScheduledActor

Functions

pub fn next_occurrence_at(now: Time, schedule: Schedule) -> Time

Returns the time of the next occurrence for the given schedule.

pub fn start(
  do do_work: fn() -> Nil,
  runs schedule: Schedule,
) -> Result(ScheduledActor, StartError)

Starts a new ScheduledActor that executes the given function on the specified schedule.

Search Document