bg_jobs/scheduled_job
Types
pub type DateError {
DateError(tempo.DateOutOfBoundsError)
TimeError(tempo.TimeOutOfBoundsError)
OutOfBoundsError(String)
RangeError(String)
}
Constructors
-
DateError(tempo.DateOutOfBoundsError)
-
TimeError(tempo.TimeOutOfBoundsError)
-
OutOfBoundsError(String)
-
RangeError(String)
pub type DateSchedule {
DateSchedule(
second: TimeValue,
minute: TimeValue,
hour: TimeValue,
day_of_month: TimeValue,
month: TimeValue,
day_of_week: TimeValue,
)
}
Constructors
-
DateSchedule( second: TimeValue, minute: TimeValue, hour: TimeValue, day_of_month: TimeValue, month: TimeValue, day_of_week: TimeValue, )
pub type DateScheduleBuilder {
DateScheduleBuilder(
second: TimeValue,
minute: TimeValue,
hour: TimeValue,
day_of_month: TimeValue,
month: TimeValue,
day_of_week: TimeValue,
)
}
Constructors
-
DateScheduleBuilder( second: TimeValue, minute: TimeValue, hour: TimeValue, day_of_month: TimeValue, month: TimeValue, day_of_week: TimeValue, )
pub type Duration {
Millisecond(Int)
Second(Int)
Minute(Int)
Hour(Int)
Day(Int)
Week(Int)
}
Constructors
-
Millisecond(Int)
-
Second(Int)
-
Minute(Int)
-
Hour(Int)
-
Day(Int)
-
Week(Int)
pub type Schedule {
Interval(Duration)
Schedule(DateSchedule)
}
Constructors
-
Interval(Duration)
-
Schedule(DateSchedule)
pub type ScheduleBuilder {
IntervalBuilder(Duration)
ScheduleBuilder(DateScheduleBuilder)
}
Constructors
-
IntervalBuilder(Duration)
-
ScheduleBuilder(DateScheduleBuilder)
pub type Spec {
Spec(
schedule: Schedule,
worker: jobs.Worker,
max_retries: Int,
init_timeout: Int,
poll_interval: Int,
event_listeners: List(events.EventListener),
)
}
Constructors
-
Spec( schedule: Schedule, worker: jobs.Worker, max_retries: Int, init_timeout: Int, poll_interval: Int, event_listeners: List(events.EventListener), )
pub type SpecBuilder {
SpecBuilder(
schedule_builder: ScheduleBuilder,
worker: jobs.Worker,
max_retries: Int,
init_timeout: Int,
poll_interval: Int,
event_listeners: List(events.EventListener),
)
}
Constructors
-
SpecBuilder( schedule_builder: ScheduleBuilder, worker: jobs.Worker, max_retries: Int, init_timeout: Int, poll_interval: Int, event_listeners: List(events.EventListener), )
pub type TimeSelection {
Value(Int)
Range(Int, Int)
}
Constructors
-
Value(Int)
-
Range(Int, Int)
Functions
pub fn between_day_of_months(
self: ScheduleBuilder,
start: Int,
end: Int,
) -> ScheduleBuilder
Sets a range of days of the month during which the schedule should trigger.
pub fn between_day_of_weeks(
self: ScheduleBuilder,
start: Int,
end: Int,
) -> ScheduleBuilder
Sets a range of days of the week during which the schedule should trigger.
pub fn between_hours(
self: ScheduleBuilder,
start: Int,
end: Int,
) -> ScheduleBuilder
Sets a range of hours during which the schedule should trigger.
pub fn between_minutes(
self: ScheduleBuilder,
start: Int,
end: Int,
) -> ScheduleBuilder
Sets a range of minutes during which the schedule should trigger.
pub fn between_months(
self: ScheduleBuilder,
start: Int,
end: Int,
) -> ScheduleBuilder
Sets a range of months during which the schedule should trigger.
pub fn between_seconds(
self: ScheduleBuilder,
start: Int,
end: Int,
) -> ScheduleBuilder
Sets a range of seconds during which the schedule should trigger.
pub fn build(
db_adapter db_adapter: DbAdapter,
spec spec: Spec,
) -> Result(Subject(Message), StartError)
pub fn build_schedule(
schedule_in: ScheduleBuilder,
) -> Result(Schedule, DateError)
Validate and create Schedule from scheduleBuilder
pub fn every_second(self: ScheduleBuilder) -> ScheduleBuilder
Sets the schedule to trigger every second.
pub fn map_schedule_builder(
schedule: ScheduleBuilder,
f: fn(DateScheduleBuilder) -> DateScheduleBuilder,
) -> ScheduleBuilder
pub fn new_interval_days(days: Int) -> ScheduleBuilder
Create interval schedule in days
pub fn new_interval_hours(hours: Int) -> ScheduleBuilder
Create interval schedule in hours
pub fn new_interval_milliseconds(
milliseconds: Int,
) -> ScheduleBuilder
Create interval schedule in milliseconds
pub fn new_interval_minutes(minutes: Int) -> ScheduleBuilder
Create interval schedule in minutes
pub fn new_interval_seconds(seconds: Int) -> ScheduleBuilder
Create interval schedule in seconds
pub fn new_interval_weeks(weeks: Int) -> ScheduleBuilder
Create interval schedule in weeks
pub fn new_schedule() -> ScheduleBuilder
Create a new schedule that runs on the first second every minut
pub fn on_aprils(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger in April.
pub fn on_augusts(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger in August.
pub fn on_day_of_month(
self: ScheduleBuilder,
value: Int,
) -> ScheduleBuilder
Adds a specific day of the month on which the schedule should trigger. If other specific days are already set, appends the given day.
pub fn on_day_of_week(
self: ScheduleBuilder,
value: Int,
) -> ScheduleBuilder
Adds a specific day of the week on which the schedule should trigger. If other specific days are already set, appends the given day.
pub fn on_decembers(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger in December.
pub fn on_februaries(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger in February.
pub fn on_fridays(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger on Fridays.
pub fn on_hour(
self: ScheduleBuilder,
value: Int,
) -> ScheduleBuilder
Adds a specific hour at which the schedule should trigger. If other specific hours are already set, appends the given hour.
pub fn on_januaries(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger in January.
pub fn on_julies(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger in July.
pub fn on_junes(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger in June.
pub fn on_marches(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger in March.
pub fn on_mays(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger in May.
pub fn on_minute(
self: ScheduleBuilder,
value: Int,
) -> ScheduleBuilder
Adds a specific minute at which the schedule should trigger. If other specific minutes are already set, appends the given minute.
pub fn on_mondays(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger on Mondays.
pub fn on_month(
self: ScheduleBuilder,
value: Int,
) -> ScheduleBuilder
Adds a specific month in which the schedule should trigger. If other specific months are already set, appends the given month.
pub fn on_novembers(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger in November.
pub fn on_octobers(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger in October.
pub fn on_saturdays(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger on Saturdays.
pub fn on_second(
self: ScheduleBuilder,
second: Int,
) -> ScheduleBuilder
Adds a specific second at which the schedule should trigger. If other specific seconds are already set, appends the given second.
Note: the default value is to trigger on second 0 so you would need to set it to every second first and then to a specific to only get that
pub fn on_septembers(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger in September.
pub fn on_sundays(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger on Sundays.
pub fn on_thuesdays(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger on Thuesdays.
pub fn on_thursdays(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger on Thursdays.
pub fn on_wednesdays(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger on Wednesdays.
pub fn on_weekdays(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger on weekdays (Monday through Friday).
pub fn on_weekends(self: ScheduleBuilder) -> ScheduleBuilder
Shortcut function to set the schedule to trigger on weekends (Saturday and Sunday).
pub fn to_bg_jobs_error(date_error: DateError) -> BgJobError
pub fn with_event_listeners(
spec: SpecBuilder,
event_listeners: List(fn(Event) -> Nil),
) -> SpecBuilder
Set event listeners for the queue NOTE: This will override previously added workers
pub fn with_init_timeout(
spec: SpecBuilder,
init_timeout: Int,
) -> SpecBuilder
Amount of time in milli seconds the queue is given to start
pub fn with_max_retries(
spec: SpecBuilder,
max_retries: Int,
) -> SpecBuilder
Maximum times a job will be retried before being considered failed and moved to the failed_jobs table
pub fn with_poll_interval_ms(
spec: SpecBuilder,
poll_interval: Int,
) -> SpecBuilder
Time in milli seconds to wait in between checking for new jobs