Static
Static Decorators
const { job } = require('decorators'),
cron = '*/10 * * * *'
class Jobs {
@job(cron) // invalid. contains a variable
@job('*/10 * * * *') // valid
@job('*/10 * * * *', { weight: -1 }) // valid
@job('*/10 * * * *', { weight: +1 }) // invalid
@job('*/10 * * * *', { weight: 1 }) // valid
@job('*/10 * * * *', { principal: script.principal }) // invalid
@job('*/10 * * * *', { principal: consts.principals.anonymous }) // invalid. contains a variable
@job('*/10 * * * *', { principal: 'anonymous' }) // valid
doJob() {
}
}const { job } = require('decorators')
// overrides a saved job script by the same name
class Jobs {
@job('*/10 * * * *', { name: 'c_existing_job', weight: 1})
doJob() {
}
}
// overrides the statically declared job of the same name and changes the job frequency
class CustomJobs extends Jobs {
@job('*/5 * * * *', { name: 'c_existing_job', weight: 2})
doJob(...args) {
super.doJob(...args)
}
}Last updated
Was this helpful?