Feat/task scheduler - #127
Merged
Merged
Conversation
…heduleLock) Adds a Laravel-scheduler-style API for running tasks on a fixed interval, designed to work with webrium's plugin system rather than a single hand-edited schedule file: - ScheduleEvent: fluent builder (everyFiveMinutes(), dailyAt(), cron(), ...) wrapping a callback (closure, [class, method], or 'Class@method'). - CronExpression: minimal 5-field cron matcher (*, steps, ranges, lists) backing the fluent helpers. - Schedule: static registry (call()/all()/reset()) plus loadFromDirectory(), which requires every *.php file under a directory recursively (so a plugin can drop its own task file into a subdirectory without touching anyone else's file), isolating each file's own load error so one broken file can't stop the rest from registering. runDue() then runs whichever registered tasks are due, isolating each task's execution the same way — a failing task is reported via Debug::triggerError and never stops the others. - ScheduleLock: flock-based per-task lock preventing a still-running task from being started again by the next scheduler tick (single server; a shared, multi-server lock is intentionally left for later). Two new Directory aliases: 'schedules' (app/Schedules) and 'schedule_locks' (storage/framework/schedule-locks). The webrium/console counterpart (make:schedule, schedule:run) drives this from a single system cron entry, mirroring Laravel's scheduler.
Support for on-demand tooling (webrium/console's schedule:list and schedule:test) on top of the scheduler added in the previous commit: - CronExpression::nextRunDate() / ScheduleEvent::nextRunDate(): the next minute (strictly after a given reference instant, default now) the expression is due, minute-resolution, capped at ~2 years lookahead so a self-contradictory expression can't loop unbounded. - Schedule::find(): look up a registered task by its name. - Schedule::run(): run a single task immediately, bypassing its own due-check, while still going through the same overlap lock and error isolation as runDue() (runOne() is folded into this, now public, as runDue() itself uses it per due task).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.