registerJobs method
Registers the scheduled-job handler on queues, and the payload codec a
database queue needs to persist it.
Implementation
void registerJobs(DVQueues queues) {
_jobWorkflows[kind] = this;
if (const DVJobPayloadCodecs().nameFor<DVContentScheduledJob>() == null) {
const DVJobPayloadCodecs().register<DVContentScheduledJob>(
DVContentScheduledJob.codec,
);
}
queues.register<DVContentScheduledJob>((DVContentScheduledJob job) async {
final DVContentWorkflow<Object?>? workflow = _jobWorkflows[job.kind];
if (workflow == null) {
// Failing the job keeps it visible in the dead letters, where a
// deploy that dropped a workflow can be seen and retried.
throw StateError('No content workflow registered for "${job.kind}".');
}
await workflow.runScheduled(job);
});
}