Class: Parse::JobSchedule
- Inherits:
-
Object
- Object
- Object
- Parse::JobSchedule
- Defined in:
- lib/parse/model/classes/job_schedule.rb
Overview
This collection is consumed by external scheduling tooling, not by Parse Server itself. #params is stored as a JSON string (not an Object) per the canonical Parse Server schema; use #parsed_params to decode. Master-key access is typically required.
This class represents the data and columns contained in the standard Parse
_JobSchedule collection. Rows here define recurring runs for background
jobs registered via Parse.Cloud.job(...). The collection is populated by
the Parse Dashboard's "Schedule a Job" UI and consumed by Parse Server's
scheduler.
The default schema for JobSchedule is as follows:
class Parse::JobSchedule < Parse::Object
# See Parse::Object for inherited properties...
property :job_name
property :description
property :params # JSON-encoded string of params (server stores as String)
property :start_after # ISO 8601 timestamp string for first run
property :days_of_week, :array
property :time_of_day # "HH:MM:SS"
property :last_run, :integer # epoch seconds of the previous run
property :repeat_minutes, :integer
end
Defining and scheduling a job
The job itself is registered in Parse Server's Cloud Code (server-side
JavaScript). See JobStatus for the Parse.Cloud.job(...)
registration example.
Schedules are normally created through the Parse Dashboard "Jobs" tab,
which writes the _JobSchedule row for you. The dashboard exposes:
- the registered job name to invoke
- the parameters to pass (serialized to {#params} as JSON)
- the start time ({#start_after}) and time-of-day ({#time_of_day})
- the days of the week ({#days_of_week}) or repeat interval
({#repeat_minutes}) at which the run should fire
_JobSchedule is a metadata collection: it stores schedule definitions
but Parse Server itself does not auto-trigger jobs from these rows. The
actual dispatch is performed by external tooling (e.g.
parse-server-scheduler, dashboard-driven cron wrappers, or a sidecar
process) which reads _JobSchedule and fires POST /parse/jobs/<name>
at the appropriate times. Run status rows then appear in
JobStatus.
Reading a schedule from Ruby
schedule = Parse::JobSchedule.for_job("nightlyCleanup").first
schedule.parsed_params # => { "dryRun" => false } (decoded from `params`)
schedule.time_of_day # => "03:00:00"
schedule.days_of_week # => ["mon","tue","wed","thu","fri"]
Instance Attribute Summary collapse
-
#days_of_week ⇒ Array
Array of day-of-week identifiers indicating which days the job is eligible to run.
-
#description ⇒ String
Free-form description of this scheduled job, as entered in the dashboard.
-
#job_name ⇒ String
The registered job name to invoke on each run.
-
#last_run ⇒ Integer
Raw
Numbertimestamp recording the previous run. -
#params ⇒ String
JSON-encoded string of parameters to pass to the job.
-
#repeat_minutes ⇒ Integer
Interval in minutes between runs, when the schedule is interval-based rather than time-of-day-based.
-
#start_after ⇒ String
ISO 8601 timestamp string indicating the earliest time the first scheduled run may fire.
-
#time_of_day ⇒ String
"HH:MM:SS" string indicating the time of day at which the job should run on each eligible day.
Class Method Summary collapse
-
.for_job(name) ⇒ Parse::Query
Query scope for schedules belonging to a specific job by name.
Instance Method Summary collapse
-
#parsed_params ⇒ Hash?
Decoded form of #params, which is stored on the wire as a JSON string per the canonical Parse Server schema.
Instance Attribute Details
#days_of_week ⇒ Array
Array of day-of-week identifiers indicating which days the job is
eligible to run. The exact token set (e.g. +"mon"+/+"tue"+/... vs.
0..+6+) is determined by the scheduler tooling that writes the row;
the Parse Server schema only requires that the column hold an array.
107 |
# File 'lib/parse/model/classes/job_schedule.rb', line 107 property :days_of_week, :array |
#description ⇒ String
Free-form description of this scheduled job, as entered in the dashboard.
86 |
# File 'lib/parse/model/classes/job_schedule.rb', line 86 property :description |
#job_name ⇒ String
The registered job name to invoke on each run.
80 |
# File 'lib/parse/model/classes/job_schedule.rb', line 80 property :job_name |
#last_run ⇒ Integer
Raw Number timestamp recording the previous run. The unit is
scheduler-defined — most external schedulers write Date.now()
milliseconds, but the canonical Parse Server schema only declares
Number and does not pin a unit. Treat values written by one
scheduler as opaque to others.
122 |
# File 'lib/parse/model/classes/job_schedule.rb', line 122 property :last_run, :integer |
#params ⇒ String
JSON-encoded string of parameters to pass to the job. Stored as a String in the canonical Parse Server schema to avoid the nested-key character restrictions that apply to Object columns.
93 |
# File 'lib/parse/model/classes/job_schedule.rb', line 93 property :params |
#repeat_minutes ⇒ Integer
Interval in minutes between runs, when the schedule is interval-based rather than time-of-day-based.
128 |
# File 'lib/parse/model/classes/job_schedule.rb', line 128 property :repeat_minutes, :integer |
#start_after ⇒ String
ISO 8601 timestamp string indicating the earliest time the first scheduled run may fire.
99 |
# File 'lib/parse/model/classes/job_schedule.rb', line 99 property :start_after |
#time_of_day ⇒ String
"HH:MM:SS" string indicating the time of day at which the job should run on each eligible day.
113 |
# File 'lib/parse/model/classes/job_schedule.rb', line 113 property :time_of_day |
Class Method Details
.for_job(name) ⇒ Parse::Query
Query scope for schedules belonging to a specific job by name.
134 135 136 |
# File 'lib/parse/model/classes/job_schedule.rb', line 134 def for_job(name) query(job_name: name.to_s) end |
Instance Method Details
#parsed_params ⇒ Hash?
Decoded form of #params, which is stored on the wire as a JSON
string per the canonical Parse Server schema. Returns the parsed
Hash, or nil if params is blank, or nil if the stored string is
not valid JSON (Parse Dashboard occasionally writes a non-JSON
description string here for ad-hoc schedules — we swallow the parse
error rather than crash the caller).
146 147 148 149 150 151 |
# File 'lib/parse/model/classes/job_schedule.rb', line 146 def parsed_params return nil if params.blank? JSON.parse(params) rescue JSON::ParserError nil end |