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

int
secondsUntil(DateInterval|DateTimeInterface|int $delay)

Get the number of seconds until the given DateTime.

int
availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)

Get the "available at" UNIX timestamp.

parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)

If the given value is an interval, convert it to a DateTime instance.

int
currentTime()

Get the current system time as a UNIX timestamp.

string
runTimeForHumans(float $startTime, float|null $endTime = null)

Given a start time, format the total run time for human readability.

static void
macro(string $name, callable|object $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Check if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls into the schedule instance.

__construct(DateTimeZone|string|null $timezone = null)

Create a new schedule instance.

call(callable|string|array $callback, array $parameters = [])

Add a new callback event to the schedule.

command(Command|string $command, array $parameters = [])

Add a new Artisan command event to the schedule.

job(object|string $job, UnitEnum|string|null $queue = null, UnitEnum|string|null $connection = null)

Add a new job callback event to the schedule.

void
dispatchToQueue(object $job, string|null $queue, string|null $connection)

Dispatch the given job to the queue.

void
dispatchUniqueJobToQueue(object $job, string|null $queue, string|null $connection)

Dispatch the given unique job to the queue.

void
dispatchNow(object $job)

Dispatch the given job right now.

exec(string $command, array $parameters = [], bool $isSystem = true)

Add a new command event to the schedule.

void
group(Closure $events)

Create new schedule group.

void
mergePendingAttributes(Event $event)

Merge the current group attributes with the given event.

string
compileParameters(array $parameters)

Compile parameters for a command.

string
compileArrayInput(int|string $key, array $value)

Compile array input for a command.

bool
serverShouldRun(Event $event, DateTimeInterface $time)

Determine if the server is allowed to run this event.

dueEvents(Application $app)

Get all of the events on the schedule that are due.

dueEventsAt(Application $app, DateTimeInterface $time)

Get all of the events on the schedule that are due at the given time.

array
events()

Get all of the events on the schedule.

array
eventsForEnvironments(array $environments)

Get all of the events on the schedule which run on any of the provided environments.

useCache(UnitEnum|string|null $store)

Specify the cache store that should be used to store mutexes.

getDispatcher()

Get the job dispatcher, if available.

static void
withoutInterruptionPolling()

Indicate that the scheduler should not poll for pause or interrupt signals.

bool
hasBeenInterruptedSince(DateTimeInterface $time)

Determine if the schedule has been interrupted since the given time.

static void
alwaysOnOneServer(bool $value = true)

Indicate that every event on the schedule should only run on one server for each cron expression.

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.

static void
flushState()

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.

Parameters

DateInterval|DateTimeInterface|int $delay

Return Value

int

in InteractsWithTime at line 29
protected int availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)

Get the "available at" UNIX timestamp.

Parameters

DateInterval|DateTimeInterface|int|null $delay

Return Value

int

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.

Parameters

DateInterval|DateTimeInterface|int|null $delay

Return Value

DateTimeInterface|int

in InteractsWithTime at line 63
protected int currentTime()

Get the current system time as a UNIX timestamp.

Return Value

int

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.

Parameters

float $startTime
float|null $endTime

Return Value

string

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.

Parameters

string $name
callable|object $macro

Return Value

void

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.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 61
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

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.

Return Value

void

in Macroable at line 83
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 606
mixed __call(string $method, array $parameters)

Dynamically handle calls into the schedule instance.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 134
__construct(DateTimeZone|string|null $timezone = null)

Create a new schedule instance.

Parameters

DateTimeZone|string|null $timezone

the timezone the date should be evaluated on

at line 151
CallbackEvent call(callable|string|array $callback, array $parameters = [])

Add a new callback event to the schedule.

Parameters

callable|string|array $callback
array $parameters

Return Value

CallbackEvent

at line 168
Event command(Command|string $command, array $parameters = [])

Add a new Artisan command event to the schedule.

Parameters

Command|string $command
array $parameters

Return Value

Event

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.

Parameters

object|string $job
UnitEnum|string|null $queue
UnitEnum|string|null $connection

Return Value

CallbackEvent

at line 242
protected void dispatchToQueue(object $job, string|null $queue, string|null $connection)

Dispatch the given job to the queue.

Parameters

object $job
string|null $queue
string|null $connection

Return Value

void

Exceptions

RuntimeException

at line 263
protected void dispatchUniqueJobToQueue(object $job, string|null $queue, string|null $connection)

Dispatch the given unique job to the queue.

Parameters

object $job
string|null $queue
string|null $connection

Return Value

void

Exceptions

RuntimeException

at line 287
protected void dispatchNow(object $job)

Dispatch the given job right now.

Parameters

object $job

Return Value

void

at line 295
Event exec(string $command, array $parameters = [], bool $isSystem = true)

Add a new command event to the schedule.

Parameters

string $command
array $parameters
bool $isSystem

Return Value

Event

at line 313
void group(Closure $events)

Create new schedule group.

Parameters

Closure $events

Return Value

void

Exceptions

RuntimeException

at line 330
protected void mergePendingAttributes(Event $event)

Merge the current group attributes with the given event.

Parameters

Event $event

Return Value

void

at line 351
protected string compileParameters(array $parameters)

Compile parameters for a command.

Parameters

array $parameters

Return Value

string

at line 369
string compileArrayInput(int|string $key, array $value)

Compile array input for a command.

Parameters

int|string $key
array $value

Return Value

string

at line 391
bool serverShouldRun(Event $event, DateTimeInterface $time)

Determine if the server is allowed to run this event.

Parameters

Event $event
DateTimeInterface $time

Return Value

bool

at line 406
Collection dueEvents(Application $app)

Get all of the events on the schedule that are due.

Parameters

Application $app

Return Value

Collection

at line 414
Collection dueEventsAt(Application $app, DateTimeInterface $time)

Get all of the events on the schedule that are due at the given time.

Parameters

Application $app
DateTimeInterface $time

Return Value

Collection

at line 425
array events()

Get all of the events on the schedule.

Return Value

array

at line 446
array eventsForEnvironments(array $environments)

Get all of the events on the schedule which run on any of the provided environments.

Parameters

array $environments

Return Value

array

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.

Parameters

UnitEnum|string|null $store

Return Value

Schedule

at line 487
protected Dispatcher getDispatcher()

Get the job dispatcher, if available.

Return Value

Dispatcher

Exceptions

RuntimeException

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.

Return Value

void

at line 522
bool hasBeenInterruptedSince(DateTimeInterface $time)

Determine if the schedule has been interrupted since the given time.

Parameters

DateTimeInterface $time

Return Value

bool

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.

Parameters

bool $value

Return Value

void

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.

Parameters

DateTimeInterface|CarbonInterval|float|int $threshold
callable $handler

Return Value

void

at line 593
static void flushState()

Flush all static state.

Return Value

void