Skip to content
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

Jobs require a manual factory #7

Open
drauschenbach opened this issue Feb 5, 2017 · 1 comment
Open

Jobs require a manual factory #7

drauschenbach opened this issue Feb 5, 2017 · 1 comment

Comments

@drauschenbach
Copy link
Contributor

Normally jobs in an Express app require some sort of access to the application object, where locals hold references to db & redis adapters, and configuration.

The current klass_finder.js architecture seems to prevent me from writing a job handler that has access to the current application context.

Injecting my own klassFinder into a worker might be one way for me to control construction of the job class handlers, so that I can pass the app context.

@drauschenbach
Copy link
Contributor Author

drauschenbach commented Feb 5, 2017

Possible work-around:

// app.js
let client = new qless.Client(redisUrl)
client.app = myExpressApp
// jobs/myJob.js
module.exports = {
  perform(job, cb) {
    job.client.app.locals.db.store(..., cb)
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant