Quik Framework :: Scheduler
- Codename: Berlin
- Version: 0.2.0-beta.76
- License: Check license here
Implements a job and task scheduler. Depending on configuration it loads the appropriate executor (optionally database-based) and starts it during application boot.
Installation
npm install @quik/scheduler
Configuration
SCHEDULER_EXECUTOR_DATABASEenables the database-backed executor.SCHEDULER_MAX_CONCURRENCYlimits concurrent task executions (default:1).
The scheduler uses app.timezone (default UTC) to evaluate cron expressions.
Usage
Define and register a task:
import { QTask, registerTask } from '@quik/scheduler';
class CleanupTask extends QTask {
constructor() {
super('cleanup', '0 0 * * *');
}
async run() {
// cleanup work
}
}
registerTask(CleanupTask);
API Highlights
QTaskbase class for scheduled tasks.registerTask()registers tasks with the active executor.getTaskScheduler()returns the scheduler instance.QBackgroundRunnerexecutes background tasks.QExecutor.pause(taskName)— pause a running task without stopping the whole scheduler.QExecutor.resume(taskName)— resume a previously paused task.
Pause and resume
import { getTaskScheduler } from '@quik/scheduler';
const scheduler = getTaskScheduler();
// Pause a specific task
scheduler.executor.pause('cleanup');
// Resume it later
scheduler.executor.resume('cleanup');
Scheduling Guarantees
- Cron schedules run with minute-level resolution.
- Tasks will not overlap when the concurrency limit is reached. Overlapping runs are skipped and logged as drift.
Testing & Coverage
See the root instructions for details on running pnpm run test:coverage and accessing coverage artifacts.
API Reference
Generated API documentation is available in the scheduler API section.