Schedule
class Schedule mixin PendingEventAttributes
Traits
Constants
| SUNDAY |
|
| MONDAY |
|
| TUESDAY |
|
| WEDNESDAY |
|
| THURSDAY |
|
| FRIDAY |
|
| SATURDAY |
|
| protected TASK_DURATION_HANDLED_CONTEXT_KEY_PREFIX |
The context key prefix for the task a duration handler has reported in the current run. |
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| protected Event> | $events | All of the events on the schedule. |
|
| protected EventMutex | $eventMutex | The event mutex implementation. |
|
| protected SchedulingMutex | $schedulingMutex | The scheduling mutex implementation. |
|
| protected Dispatcher|null | $dispatcher | The job dispatcher implementation. |
|
| protected array<string, bool> | $mutexCache | The cache of mutex results. |
|
| protected string|null | $mutexCacheMinute | The minute currently represented by the in-memory mutex cache. |
|
| protected PendingEventAttributes|null | $attributes | The attributes to pass to the event. |
|
| protected PendingEventAttributes> | $groupStack | The schedule group attributes stack. |
|
| static bool | $pausable | Indicates if the schedule should check for the paused signal in the cache. |
|
| static bool | $interruptible | Indicates if the schedule should check for the interrupt signal in the cache. |
|
| static bool | $alwaysOnOneServer | Indicates if every event should only run on one server for each cron expression. |
Methods
Get the number of seconds until the given DateTime.
Get the "available at" UNIX timestamp.
If the given value is an interval, convert it to a DateTime instance.
Given a start time, format the total run time for human readability.
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls into the schedule instance.
Add a new callback event to the schedule.
Add a new Artisan command event to the schedule.
Add a new job callback event to the schedule.
Dispatch the given job to the queue.
Dispatch the given unique job to the queue.
Dispatch the given job right now.
Add a new command event to the schedule.
Compile parameters for a command.
Compile array input for a command.
Determine if the server is allowed to run this event.
Get all of the events on the schedule that are due at the given time.
Get all of the events on the schedule.
Get all of the events on the schedule which run on any of the provided environments.
Specify the cache store that should be used to store mutexes.
Get the job dispatcher, if available.
Indicate that the scheduler should not poll for pause or interrupt signals.
Determine if the schedule has been interrupted since the given time.
Indicate that every event on the schedule should only run on one server for each cron expression.
Register a callback to be invoked when a scheduled task runs for longer than a given amount of time.
Flush all static state.
Details
in
InteractsWithTime at line 17
protected int
secondsUntil(DateInterval|DateTimeInterface|int $delay)
Get the number of seconds until the given DateTime.
in
InteractsWithTime at line 29
protected int
availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)
Get the "available at" UNIX timestamp.
in
InteractsWithTime at line 47
protected DateTimeInterface|int
parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)
If the given value is an interval, convert it to a DateTime instance.
in
InteractsWithTime at line 63
protected int
currentTime()
Get the current system time as a UNIX timestamp.
in
InteractsWithTime at line 71
protected string
runTimeForHumans(float $startTime, float|null $endTime = null)
Given a start time, format the total run time for human readability.
in
Macroable at line 30
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 44
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 61
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 72
static void
flushMacros()
Flush the existing macros.
Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 83
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
at line 606
mixed
__call(string $method, array $parameters)
Dynamically handle calls into the schedule instance.
at line 134
__construct(DateTimeZone|string|null $timezone = null)
Create a new schedule instance.
at line 151
CallbackEvent
call(callable|string|array $callback, array $parameters = [])
Add a new callback event to the schedule.
at line 168
Event
command(Command|string $command, array $parameters = [])
Add a new Artisan command event to the schedule.
at line 196
CallbackEvent
job(object|string $job, UnitEnum|string|null $queue = null, UnitEnum|string|null $connection = null)
Add a new job callback event to the schedule.
at line 242
protected void
dispatchToQueue(object $job, string|null $queue, string|null $connection)
Dispatch the given job to the queue.
at line 263
protected void
dispatchUniqueJobToQueue(object $job, string|null $queue, string|null $connection)
Dispatch the given unique job to the queue.
at line 287
protected void
dispatchNow(object $job)
Dispatch the given job right now.
at line 295
Event
exec(string $command, array $parameters = [], bool $isSystem = true)
Add a new command event to the schedule.
at line 313
void
group(Closure $events)
Create new schedule group.
at line 330
protected void
mergePendingAttributes(Event $event)
Merge the current group attributes with the given event.
at line 351
protected string
compileParameters(array $parameters)
Compile parameters for a command.
at line 369
string
compileArrayInput(int|string $key, array $value)
Compile array input for a command.
at line 391
bool
serverShouldRun(Event $event, DateTimeInterface $time)
Determine if the server is allowed to run this event.
at line 406
Collection
dueEvents(Application $app)
Get all of the events on the schedule that are due.
at line 414
Collection
dueEventsAt(Application $app, DateTimeInterface $time)
Get all of the events on the schedule that are due at the given time.
at line 425
array
events()
Get all of the events on the schedule.
at line 446
array
eventsForEnvironments(array $environments)
Get all of the events on the schedule which run on any of the provided environments.
at line 462
Schedule
useCache(UnitEnum|string|null $store)
Specify the cache store that should be used to store mutexes.
Mutates the shared mutex instances used by this worker's schedule; per-request use races across coroutines.
at line 487
protected Dispatcher
getDispatcher()
Get the job dispatcher, if available.
at line 512
static void
withoutInterruptionPolling()
Indicate that the scheduler should not poll for pause or interrupt signals.
This prevents the scheduler from hitting the application cache to determine if it needs to pause or interrupt.
Mutates process-global scheduler flags; runtime use changes pause and interrupt behavior for every concurrent scheduler run.
at line 522
bool
hasBeenInterruptedSince(DateTimeInterface $time)
Determine if the schedule has been interrupted since the given time.
at line 539
static void
alwaysOnOneServer(bool $value = true)
Indicate that every event on the schedule should only run on one server for each cron expression.
The flag persists for the worker lifetime and affects every schedule evaluated in the process.
at line 553
void
whenTaskRunsLongerThan(DateTimeInterface|CarbonInterval|float|int $threshold, callable $handler)
Register a callback to be invoked when a scheduled task runs for longer than a given amount of time.
The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching scheduler event.
at line 593
static void
flushState()
Flush all static state.