JobLoadHandler option
Hi @RomainLanz,
As I migrated my production app from Adonis v5 to v6, and upgraded this package, I noticed that the names of all the jobs in Redis changed. Since I have a bunch of jobs scheduled for the future this creates a problem.
I forked the project, and added a optional config jobLoadHandler https://github.com/RomainLanz/adonis-bull-queue/commit/cc31cb5e71946c76184abc328580abe4e1915f65 so i could remap the old job names to the right jobs under the new setup.
async jobHandlerLoader(name: string) {
const remap = new Map([
['App/Jobs/ChargeSplitPayment', 'charge_split_payment_job'],
['App/Jobs/CheckinInstructions', 'checkin_instructions_job'],
['App/Jobs/DailyReport', 'daily_report_job'],
['App/Jobs/EmailReservationPaid', 'email_reservation_paid_job'],
])
const fileName = remap.get(name) ?? name
const { default: handler } = await import(`#app/jobs/${fileName}`)
return handler
},
This also allows me to manually specify the name of the job, which makes it much clearer in job monitoring UIs.
export default class DailyReportJob extends Job {
static get $$filepath() {
return 'daily_report_job'
}
Basically it allows you to map job class to job name in redis, and from job name in redis back to the job class.
Would you be open to me contributing some version of this back to your repo?
It's completely backwards compatible. LMK