buildbox-2.1.2.2: Rehackable components for writing buildbots and test harnesses.

Safe HaskellNone

BuildBox.Data.Schedule

Contents

Description

A schedule of commands that should be run at a certain time.

Synopsis

Time Periods

When

data When Source

When to invoke some event.

Constructors

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 ''days'' are UTC days, not local ones.

Instances

data WhenModifier Source

Modifier to when.

Constructors

Immediate

If the event hasn't been invoked before then do it immediately when we start the cron process.

WaitUntil UTCTime

Wait until after this time before doing it first.

Events

data Event Source

Records when an event should start, and when it last ran.

Constructors

Event 

Fields

eventName :: EventName

A unique name for this event. Used when writing the schedule to a file.

eventWhen :: When

When to run the command.

eventWhenModifier :: Maybe WhenModifier

Modifier to the previous.

eventLastStarted :: Maybe UTCTime

When the event was last started, if any.

eventLastEnded :: Maybe UTCTime

When the event last finished, if any.

Instances

earliestEventToStartAt :: UTCTime -> [Event] -> Maybe EventSource

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 -> BoolSource

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

data Schedule cmd Source

Map of event names to their details and build commands.

Constructors

Schedule (Map EventName (Event, cmd)) 

makeSchedule :: [(EventName, When, Maybe WhenModifier, cmd)] -> Schedule cmdSource

A nice way to produce a schedule.

lookupEventOfSchedule :: EventName -> Schedule cmd -> Maybe EventSource

Given an event name, lookup the associated event from a schedule.

lookupCommandOfSchedule :: EventName -> Schedule cmd -> Maybe cmdSource

Given an event name, lookup the associated build command from a schedule.

adjustEventOfSchedule :: Event -> Schedule cmd -> Schedule cmdSource

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.