bg_jobs/scheduled_job
Types
pub type Duration {
Millisecond(Int)
Second(Int)
Minute(Int)
Hour(Int)
Day(Int)
Week(Int)
Month(Int)
Year(Int)
}
Constructors
-
Millisecond(Int)
-
Second(Int)
-
Minute(Int)
-
Hour(Int)
-
Day(Int)
-
Week(Int)
-
Month(Int)
-
Year(Int)
pub type Schedule {
Interval(Duration)
Schedule(ScheduleBuilder)
}
Constructors
-
Interval(Duration)
-
Schedule(ScheduleBuilder)
pub type ScheduleBuilder {
ScheduleBuilder(
second: TimeValue,
minute: TimeValue,
hour: TimeValue,
day_of_month: TimeValue,
month: TimeValue,
day_of_week: TimeValue,
)
}
Constructors
-
ScheduleBuilder( second: TimeValue, minute: TimeValue, hour: TimeValue, day_of_month: TimeValue, month: TimeValue, day_of_week: TimeValue, )
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 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(
registry registry: Subject(
Message(
bg_jobs/internal/scheduled_jobs_messages.Message,
String,
Nil,
),
),
dispatch_registry dispatch_registry: Subject(
Message(
bg_jobs/internal/dispatcher_messages.Message,
String,
Nil,
),
),
db_adapter db_adapter: DbAdapter,
spec spec: Spec,
) -> Result(
Subject(bg_jobs/internal/scheduled_jobs_messages.Message),
StartError,
)
pub fn build_schedule(schedule: ScheduleBuilder) -> Schedule
Create Schedule from scheduleBuilder
pub fn every_second(self: ScheduleBuilder) -> ScheduleBuilder
Sets the schedule to trigger every second.
pub fn new_interval_days(days: Int) -> Schedule
Create interval schedule in days
pub fn new_interval_hours(hours: Int) -> Schedule
Create interval schedule in hours
pub fn new_interval_milliseconds(milliseconds: Int) -> Schedule
Create interval schedule in milliseconds
pub fn new_interval_minutes(minutes: Int) -> Schedule
Create interval schedule in minutes
pub fn new_interval_months(months: Int) -> Schedule
Create interval schedule in months
pub fn new_interval_seconds(seconds: Int) -> Schedule
Create interval schedule in seconds
pub fn new_interval_weeks(weeks: Int) -> Schedule
Create interval schedule in weeks
pub fn new_interval_years(years: Int) -> Schedule
Create interval schedule in years
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_cron_syntax(self: ScheduleBuilder) -> String
Convert the ScheduleBuilder to actual cron syntax
pub fn with_event_listeners(
spec: Spec,
event_listeners: List(fn(Event) -> Nil),
) -> Spec
Set event listeners for the queue NOTE: This will override previously added workers
pub fn with_init_timeout(spec: Spec, init_timeout: Int) -> Spec
Amount of time in milli seconds the queue is given to start
pub fn with_max_retries(spec: Spec, max_retries: Int) -> Spec
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: Spec,
poll_interval: Int,
) -> Spec
Time in milli seconds to wait in between checking for new jobs