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

Skip to content

[Scheduler] Improve triggers performance when possible #49817

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
Show file tree
Hide file tree
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
20 changes: 12 additions & 8 deletions src/Symfony/Component/Scheduler/RecurringMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

use Symfony\Component\Scheduler\Exception\InvalidArgumentException;
use Symfony\Component\Scheduler\Trigger\CronExpressionTrigger;
use Symfony\Component\Scheduler\Trigger\DateIntervalTrigger;
use Symfony\Component\Scheduler\Trigger\JitterTrigger;
use Symfony\Component\Scheduler\Trigger\PeriodicalTrigger;
use Symfony\Component\Scheduler\Trigger\TriggerInterface;

/**
Expand All @@ -31,17 +31,21 @@ private function __construct(
}

/**
* Uses a relative date format to define the frequency.
* Sets the trigger frequency.
*
* Supported frequency formats:
*
* * An integer to define the frequency as a number of seconds;
* * An ISO 8601 duration format;
* * A relative date format as supported by \DateInterval;
* * A \DateInterval instance.
*
* @see https://en.wikipedia.org/wiki/ISO_8601#Durations
* @see https://php.net/datetime.formats.relative
*/
public static function every(string $frequency, object $message, string|\DateTimeImmutable $from = new \DateTimeImmutable(), string|\DateTimeImmutable $until = new \DateTimeImmutable('3000-01-01')): self
public static function every(string|int|\DateInterval $frequency, object $message, string|\DateTimeImmutable $from = new \DateTimeImmutable(), string|\DateTimeImmutable $until = new \DateTimeImmutable('3000-01-01')): self
{
if (false === $interval = \DateInterval::createFromDateString($frequency)) {
throw new InvalidArgumentException(sprintf('Frequency "%s" cannot be parsed.', $frequency));
}

return new self(new DateIntervalTrigger($interval, $from, $until), $message);
return new self(new PeriodicalTrigger($frequency, $from, $until), $message);
}

public static function cron(string $expression, object $message): self
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading