-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Scheduler] Add new component documentation #18136
Conversation
public function getSchedule(string $id): Schedule | ||
{ | ||
return (new Schedule()) | ||
->add(new RecurringMessage::every('1 week', new EndofTrialMessage())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new
keyword should not be there 😉
->add(new RecurringMessage::every('1 week', new EndofTrialMessage())) | |
->add(RecurringMessage::every('1 week', new EndofTrialMessage())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent start!
Register a Schedule provider | ||
---------------------------- | ||
|
||
A Schedule provider is a class defining your schedule : which messages should |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A Schedule provider is a class defining your schedule : which messages should | |
A Schedule provider is a class defining your schedule. Which messages should |
---------------------------- | ||
|
||
A Schedule provider is a class defining your schedule : which messages should | ||
be processed depending a trigger you choose:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be processed depending a trigger you choose:: | |
be processed depends on the trigger you choose:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be processed depending a trigger you choose:: | |
be processed depending on the trigger you choose: |
use Symfony\Component\Scheduler\Schedule; | ||
use Symfony\Component\Scheduler\ScheduleProviderInterface; | ||
|
||
#[AsSchedule('trial')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[AsSchedule('trial')] | |
#[AsSchedule('default')] |
I'm thinking we should just use default here. Multiple schedules is an advanced use-case imo.
use Symfony\Component\Scheduler\ScheduleProviderInterface; | ||
|
||
#[AsSchedule('trial')] | ||
final class EndOfTrialScheduleProvider implements ScheduleProviderInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final class EndOfTrialScheduleProvider implements ScheduleProviderInterface | |
final class AppSchedule implements ScheduleProviderInterface |
|
||
.. code-block:: terminal | ||
|
||
$ php bin/console messenger:consume scheduler_trial |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ php bin/console messenger:consume scheduler_trial | |
$ php bin/console messenger:consume scheduler_default |
`cron`. By extending the provided TriggerInterface you can also create | ||
your own trigger for your app. | ||
|
||
Every |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every | |
PeriodicalTrigger |
|
||
RecurringMessage::every('monday', $msg, until: '2023-06-12'); | ||
|
||
Cron |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cron | |
CronExpressionTrigger |
|
||
Cron | ||
~~~~ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need a note that https://github.com/dragonmantank/cron-expression is required to use this trigger.
// trigger every monday at 12:00 | ||
RecurringMessage::cron('0 12 * * 1', $msg); | ||
|
||
.. note:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should document symfony/symfony#49792
.. note:: | ||
|
||
The minimal interval allowed with cron is 1 minute. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO:
- JitterTrigger
- CallbackTrigger
- ExcludeTimeTrigger
Is there something we can help here to move this forward? Think at current state would be better to have a incomplete documentation then no documentation of the scheduler component. |
Sorry I created this PR then I've been pretty absent. @javiereguiluz Maybe we can help in some way ? |
Closing in favor of #19244 |
Fixes #18067
This is an early draft for the Scheduler component and his Messenger integration to gather early feedback
While starting the documentation, I asked myself a few questions :