Safe Haskell | Safe |
---|---|
Language | Haskell98 |
A schedule of commands that should be run at a certain time.
- second :: NominalDiffTime
- minute :: NominalDiffTime
- hour :: NominalDiffTime
- day :: NominalDiffTime
- data When
- data WhenModifier
- type EventName = String
- data Event = Event {}
- earliestEventToStartAt :: UTCTime -> [Event] -> Maybe Event
- eventCouldStartAt :: UTCTime -> Event -> Bool
- data Schedule cmd = Schedule (Map EventName (Event, cmd))
- makeSchedule :: [(EventName, When, Maybe WhenModifier, cmd)] -> Schedule cmd
- lookupEventOfSchedule :: EventName -> Schedule cmd -> Maybe Event
- lookupCommandOfSchedule :: EventName -> Schedule cmd -> Maybe cmd
- adjustEventOfSchedule :: Event -> Schedule cmd -> Schedule cmd
- eventsOfSchedule :: Schedule cmd -> [Event]
Time Periods
When
When to invoke some event.
Always | Just keep doing it. |
Never | Don't do it, ever. |
Every NominalDiffTime | Do it some time after we last started it. |
After NominalDiffTime | Do it some time after it last finished. |
Daily TimeOfDay | Do it each day at this time. The ' |
data WhenModifier Source #
Modifier to when.
Events
Records when an event should start, and when it last ran.
Event | |
|
earliestEventToStartAt :: UTCTime -> [Event] -> Maybe Event Source #
Given the current time and a list of events, determine which one should be started now. If several events are avaliable then take the one with the earliest start time.
eventCouldStartAt :: UTCTime -> Event -> Bool Source #
Given the current time, decide whether an event could be started.
If the WhenModifier
is Immediate
this always returns true.
The SkipFirst
modifier is ignored, as this is handled separately.
Schedules
Map of event names to their details and build commands.
makeSchedule :: [(EventName, When, Maybe WhenModifier, cmd)] -> Schedule cmd Source #
A nice way to produce a schedule.
lookupEventOfSchedule :: EventName -> Schedule cmd -> Maybe Event Source #
Given an event name, lookup the associated event from a schedule.
lookupCommandOfSchedule :: EventName -> Schedule cmd -> Maybe cmd Source #
Given an event name, lookup the associated build command from a schedule.
adjustEventOfSchedule :: Event -> Schedule cmd -> Schedule cmd Source #
Given a new version of an event, update any matching event in the schedule. If the event not already there then return the original schedule.
eventsOfSchedule :: Schedule cmd -> [Event] Source #
Get the list of events in a schedule, ignoring the build commands.