1.0.6 • Published 7 years ago
salak-schedule v1.0.6
salak-schedule
Cron task for salak.
Feature
- Three mode: single、worker and all.
singlemeans the task will be trigger on the only one thread in the only one machine.workermeans the task will be trigger on the only one thread in every machine.allmeans the task will be trigger on every thread
- Task can trigger service.
Install
npm install --save salak-scheduleUsage
const SalakSchedule = require('salak-schedule')
const timerHandler = new SalakSchedule({
app: this.app,
prefix,
store: new SalakSchedule.stores['memory']()
})load schedule from dir schedule under every module.
const { Service } = require('salak')
class Task extends Service {
static timer () {
return {
enable: true, // default true
interval: 1000,
type: 'all', // single、all、worker, default 'all'
cron: '* * * * * *', // use `cron-parser`
cronOptions: {}
}
}
async run () { // for the task logic
}
}API
schedule options
- Store: for
singleorworker,default redisStore - prefix: for
singleorworker,default 'salakTimer' - options: options for Store. default app.redis
Timer
getSchedules()
runSchedule(key)
- key:
${module}.${taskfilename}
closeSchedules()
Write a store
class AStore {
lock (key, ttl) {}
unlock (lock) {}
}
module.exports = AStoreLicense
MIT
2.0.0-beta.3
7 years ago
2.0.0-beta.2
7 years ago
2.0.0-beta.1
7 years ago
1.0.6
7 years ago
2.0.0-beta
8 years ago
1.0.5
8 years ago
1.0.4
8 years ago
1.0.3
8 years ago
1.0.2
8 years ago
1.0.1
8 years ago
1.0.0
8 years ago