Skip to content

Commit bab8683

Browse files
istiak-tridipstevebaumantaylorotwell
authored
[11.x] Introduce Schedule Grouping (#53427)
* Add ability to group schedules * Add missing native types * Add missing event filters * fix: cs * add missing docblocks * fix cs * re-implement * cs * fix styleci * add missing docblocks * refactor code spacing Co-authored-by: Steve Bauman <[email protected]> * fix styleci error * formatting * add files * rename method' --------- Co-authored-by: Steve Bauman <[email protected]> Co-authored-by: Taylor Otwell <[email protected]>
1 parent 29907b2 commit bab8683

File tree

5 files changed

+485
-198
lines changed

5 files changed

+485
-198
lines changed

src/Illuminate/Console/Scheduling/Event.php

+1-197
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Illuminate\Contracts\Mail\Mailer;
1313
use Illuminate\Support\Arr;
1414
use Illuminate\Support\Facades\Date;
15-
use Illuminate\Support\Reflector;
1615
use Illuminate\Support\Stringable;
1716
use Illuminate\Support\Traits\Macroable;
1817
use Illuminate\Support\Traits\ReflectsClosures;
@@ -23,7 +22,7 @@
2322

2423
class Event
2524
{
26-
use Macroable, ManagesFrequencies, ReflectsClosures, Tappable;
25+
use Macroable, ManagesAttributes, ManagesFrequencies, ReflectsClosures, Tappable;
2726

2827
/**
2928
* The command string.
@@ -32,90 +31,6 @@ class Event
3231
*/
3332
public $command;
3433

35-
/**
36-
* The cron expression representing the event's frequency.
37-
*
38-
* @var string
39-
*/
40-
public $expression = '* * * * *';
41-
42-
/**
43-
* How often to repeat the event during a minute.
44-
*
45-
* @var int|null
46-
*/
47-
public $repeatSeconds = null;
48-
49-
/**
50-
* The timezone the date should be evaluated on.
51-
*
52-
* @var \DateTimeZone|string
53-
*/
54-
public $timezone;
55-
56-
/**
57-
* The user the command should run as.
58-
*
59-
* @var string|null
60-
*/
61-
public $user;
62-
63-
/**
64-
* The list of environments the command should run under.
65-
*
66-
* @var array
67-
*/
68-
public $environments = [];
69-
70-
/**
71-
* Indicates if the command should run in maintenance mode.
72-
*
73-
* @var bool
74-
*/
75-
public $evenInMaintenanceMode = false;
76-
77-
/**
78-
* Indicates if the command should not overlap itself.
79-
*
80-
* @var bool
81-
*/
82-
public $withoutOverlapping = false;
83-
84-
/**
85-
* Indicates if the command should only be allowed to run on one server for each cron expression.
86-
*
87-
* @var bool
88-
*/
89-
public $onOneServer = false;
90-
91-
/**
92-
* The number of minutes the mutex should be valid.
93-
*
94-
* @var int
95-
*/
96-
public $expiresAt = 1440;
97-
98-
/**
99-
* Indicates if the command should run in the background.
100-
*
101-
* @var bool
102-
*/
103-
public $runInBackground = false;
104-
105-
/**
106-
* The array of filter callbacks.
107-
*
108-
* @var array
109-
*/
110-
protected $filters = [];
111-
112-
/**
113-
* The array of reject callbacks.
114-
*
115-
* @var array
116-
*/
117-
protected $rejects = [];
118-
11934
/**
12035
* The location that output should be sent to.
12136
*
@@ -666,117 +581,6 @@ protected function getHttpClient(Container $container)
666581
};
667582
}
668583

669-
/**
670-
* State that the command should run in the background.
671-
*
672-
* @return $this
673-
*/
674-
public function runInBackground()
675-
{
676-
$this->runInBackground = true;
677-
678-
return $this;
679-
}
680-
681-
/**
682-
* Set which user the command should run as.
683-
*
684-
* @param string $user
685-
* @return $this
686-
*/
687-
public function user($user)
688-
{
689-
$this->user = $user;
690-
691-
return $this;
692-
}
693-
694-
/**
695-
* Limit the environments the command should run in.
696-
*
697-
* @param array|mixed $environments
698-
* @return $this
699-
*/
700-
public function environments($environments)
701-
{
702-
$this->environments = is_array($environments) ? $environments : func_get_args();
703-
704-
return $this;
705-
}
706-
707-
/**
708-
* State that the command should run even in maintenance mode.
709-
*
710-
* @return $this
711-
*/
712-
public function evenInMaintenanceMode()
713-
{
714-
$this->evenInMaintenanceMode = true;
715-
716-
return $this;
717-
}
718-
719-
/**
720-
* Do not allow the event to overlap each other.
721-
*
722-
* The expiration time of the underlying cache lock may be specified in minutes.
723-
*
724-
* @param int $expiresAt
725-
* @return $this
726-
*/
727-
public function withoutOverlapping($expiresAt = 1440)
728-
{
729-
$this->withoutOverlapping = true;
730-
731-
$this->expiresAt = $expiresAt;
732-
733-
return $this->skip(function () {
734-
return $this->mutex->exists($this);
735-
});
736-
}
737-
738-
/**
739-
* Allow the event to only run on one server for each cron expression.
740-
*
741-
* @return $this
742-
*/
743-
public function onOneServer()
744-
{
745-
$this->onOneServer = true;
746-
747-
return $this;
748-
}
749-
750-
/**
751-
* Register a callback to further filter the schedule.
752-
*
753-
* @param \Closure|bool $callback
754-
* @return $this
755-
*/
756-
public function when($callback)
757-
{
758-
$this->filters[] = Reflector::isCallable($callback) ? $callback : function () use ($callback) {
759-
return $callback;
760-
};
761-
762-
return $this;
763-
}
764-
765-
/**
766-
* Register a callback to further filter the schedule.
767-
*
768-
* @param \Closure|bool $callback
769-
* @return $this
770-
*/
771-
public function skip($callback)
772-
{
773-
$this->rejects[] = Reflector::isCallable($callback) ? $callback : function () use ($callback) {
774-
return $callback;
775-
};
776-
777-
return $this;
778-
}
779-
780584
/**
781585
* Register a callback to be called before the operation.
782586
*

0 commit comments

Comments
 (0)