-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Labels
RFCRFC = Request For Comments (proposals about features that you want to be discussed)RFC = Request For Comments (proposals about features that you want to be discussed)Scheduler
Description
Description
Currently, it takes a lot of effort to create a scheduled task.
- define schedule provider
- create a message class
- create a messenger handler.
These steps look too redundant, if you need to create a couple of simple tasks such as cleaning archive dir, check users, etc.
Proposal
To simplify using of the scheduled tasks, proposed add AsPeriodicTask
and AsCronTask
attributes. They can be added as class or method attributes to any symfony service or console command.
Additionally, it is need to allow the merging of scheduled tasks obtained from schedule providers with the same name.
#[AsPeriodicTask('1 day')]
#[AsCronTask('35,45,55 */3 * * *', jitter: 60, arguments: ['level' => '500mb'])]
#[AsCronTask('@random 3600', schedule: 'default')]
Example
<?php declare(strict_types=1);
namespace App\Service;
#[AsCronTask('*/5 * * * *')]
class SyncAppWorker
{
public function __invoke(array $arguments = []): void
{
// code
}
}
Sturm, yesdevnull, Seb33300, ChrisRiddell, artyuum and 4 more
Metadata
Metadata
Assignees
Labels
RFCRFC = Request For Comments (proposals about features that you want to be discussed)RFC = Request For Comments (proposals about features that you want to be discussed)Scheduler