-
Notifications
You must be signed in to change notification settings - Fork 0
Tasks
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`);
}
}
- Controllers
- Middleware
- Autowire
- Plugins
- Tasks
- Fibres
- Authentication
- Registry
- Services
- Dependecy Injection
- Translations (i18n)
- Safe Quit
- Exception Handling
- Event Listener
- Custom Logger
- HTTP Plugin - Built-In
- WS Plugin - Built-In
- Discord Plugin - External
- Vite Plugin - External
- Inspect Plugin - External
- CLI Plugin - External
- Got an issue? Join our Discord
- Need your own plugin? Contact Me
- Have an idea? Let's Discuss
- Want to support me? Buy me a coffee