Commit 3b29817
committed
feature #50270 [Scheduler] add
This PR was merged into the 6.3 branch.
Discussion
----------
[Scheduler] add `JitterTrigger`
| Q | A
| ------------- | ---
| Branch? | 6.4
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | #49806
|
8000
License | MIT
| Doc PR | n/a
I think this is what `@vtsykun` was trying to accomplish with #49806. FreeBSD has a `-jitter` option that does the same thing so I think there's precedent. From the (https://man.freebsd.org/cgi/man.cgi?cron):
> -j jitter
> Enable time jitter. Prior to executing commands, cron will sleep
a random number of seconds in the range from 0 to jitter. ~This
will not affect superuser jobs (see -J).~ A value for jitter must
be between 0 and 60 inclusive. Default is 0, which effectively
disables time jitter.
> This option can help to smooth down system load spikes during mo-
ments when a lot of jobs are likely to start at once, e.g., at
the beginning of the first minute of each hour.
Usage:
```php
// defaults to 0-60 seconds
$schedule->add(RecurringMessage::cron('`@daily`', $message1)->withJitter());
// customize the max seconds (0-30)
$schedule->add(RecurringMessage::cron('`@daily`', $message1)->withJitter(30));
```
Commits
-------
b0d984b [Scheduler] add `JitterTrigger`JitterTrigger (kbond)File tree
3 files changed
+87
-0
lines changed- src/Symfony/Component/Scheduler
- Tests/Trigger
- Trigger
3 files changed
+87
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
62 | 68 | | |
63 | 69 | | |
64 | 70 | | |
| |||
Lines changed: 42 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
0 commit comments