-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev-mode Suggestion #39
Labels
Comments
Yup, it could be doable, same with #20 |
For now I just made a BaseJob that all other jobs inherit from import Application from '@ioc:Adonis/Core/Application'
import { JobHandlerContract, Queue, type Job } from '@ioc:Rlanz/Queue'
export default class BaseJob implements JobHandlerContract {
// needs to be implemented in each job, imports cannot be inherited properly
public static get $$filepath(): string {
// must be implemented by subclass
throw new Error('Must be implemented by subclass')
}
constructor(public job: Job) {
this.job = job
}
public static async run(payload) {
const job = new this(payload)
if (Application.inDev) {
job.handle(payload)
} else {
Queue.dispatch(this.$$filepath, payload)
}
}
/**
* Base Entry point
*/
public async handle(payload: any) {}
/**
* This is an optional method that gets called if it exists when the retries has exceeded and is marked failed.
*/
public async failed() {}
} so I'll just call the class method of |
Open
What do you think of having a flag in the configuration? defineConfig({
instant: true // or immediate or sync or ...
}) (I am not sure about the name) |
I like that approach! Easily configurable per environment which would be great :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The option to run the jobs synchronously in development would be really nice.
Is this possible with the current state of the package?
The text was updated successfully, but these errors were encountered: