Skip to content
Danny edited this page Feb 16, 2022 · 3 revisions

A task in the Turbo engine is a class that implements ITask. The task can run certain things at specific times (based on cron expressions) allowing you to run daily cleanups of a database, or sending a daily report to a mailing list. You can of course import and use fibres in this context for more CPU-intensive work.

All tasks will notify you how long they have taken, this allows you to track timings for server issues, we shall soon be offering a debug mode that allows you to track all operations of the Turbo framework and their timings.

Has full application scope, unlike fibres.

import { Inject } from '@symbux/injector';
import { Task, ILogger } from '../../src';

interface ITask {
	execute: () => Promise<void>;
}

@Task('memory', '*/15 * * * *')
export default class MemoryTask implements ITask {

	@Inject('logger') private logger!: ILogger;

	public async execute(): Promise<void> {
		const used = process.memoryUsage().heapUsed / 1024 / 1024;
		this.logger.info('TASK:MEMORY', `Application is using approximately ${Math.round(used * 100) / 100} MB`);
	}
}

Features

Plugins

Future Plans

Resources

Clone this wiki locally