Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Scheduler] Fix scheduler examples #19440

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

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions scheduler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ the task of creating a report::

class SendDailySalesReports
{
public function __construct(private string $id) {}
public function __construct(private int $id) {}

public function getId(): int
{
Expand All @@ -61,6 +61,9 @@ Next, create the handler that processes that kind of message::
// src/Scheduler/Handler/SendDailySalesReportsHandler.php
namespace App\Scheduler\Handler;

use App\Scheduler\Message\SendDailySalesReports;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;

#[AsMessageHandler]
class SendDailySalesReportsHandler
{
Expand Down Expand Up @@ -105,9 +108,13 @@ The :class:`Symfony\\Component\\Scheduler\\Attribute\\AsSchedule` attribute,
which by default references the schedule named ``default``, allows you to register
on a particular schedule::

// src/Scheduler/MyScheduleProvider.php
// src/Scheduler/SaleTaskProvider.php
namespace App\Scheduler;

use Symfony\Component\Scheduler\Attribute\AsSchedule;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How code-block-checker can know theses classes ?

Is adding symfony/scheduler in its compoer.json will be enought ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this should be enough

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged

use Symfony\Component\Scheduler\Schedule;
use Symfony\Component\Scheduler\ScheduleProviderInterface;

#[AsSchedule]
class SaleTaskProvider implements ScheduleProviderInterface
{
Expand Down Expand Up @@ -260,7 +267,7 @@ Then, define your recurring message::

Finally, the recurring messages has to be attached to a schedule::

// src/Scheduler/MyScheduleProvider.php
// src/Scheduler/SaleTaskProvider.php
namespace App\Scheduler;

#[AsSchedule('uptoyou')]
Expand Down Expand Up @@ -344,7 +351,7 @@ via the ``stateful`` option (and the :doc:`Cache component </components/cache>`)
This way, when it wakes up again, it looks at all the dates and can catch up on
what it missed::

// src/Scheduler/MyScheduleProvider.php
// src/Scheduler/SaleTaskProvider.php
namespace App\Scheduler;

#[AsSchedule('uptoyou')]
Expand All @@ -366,7 +373,7 @@ To scale your schedules more effectively, you can use multiple workers. In such
cases, a good practice is to add a :doc:`lock </components/lock>` to prevent the
same task more than once::

// src/Scheduler/MyScheduleProvider.php
// src/Scheduler/SaleTaskProvider.php
namespace App\Scheduler;

#[AsSchedule('uptoyou')]
Expand Down Expand Up @@ -395,7 +402,7 @@ your message in a :class:`Symfony\\Component\\Messenger\\Message\\RedispatchMess
This allows you to specify a transport on which your message will be redispatched
before being further redispatched to its corresponding handler::

// src/Scheduler/MyScheduleProvider.php
// src/Scheduler/SaleTaskProvider.php
namespace App\Scheduler;

#[AsSchedule('uptoyou')]
Expand Down