Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Improve schedule group behaviors #53641

Merged
merged 3 commits into from
Nov 25, 2024

Conversation

istiak-tridip
Copy link
Contributor

Description

This PR improves the handling of fatal exceptions in schedule groups and introduces a new resetFrequency method. This allows developers to opt out of the default frequency set by a group and set a custom frequency for tasks, as discussed in PR #53626 with @taylorotwell.

Fix for Behavior One

The following snippets now throw exceptions with informative error messages.

// Example #1
Schedule::group(function () { // throws an exception here
    Schedule::command('command-one');
});

// Example #2
Schedule::daily()->group(function () {
    Schedule::command('command-one');
    Schedule::group(function () { // throws an exception here
        Schedule::command('command-two');
    });
});

Fix for Behavior Two

Developers can now opt out of a group’s preset frequency and apply a custom frequency to a scheduled task:

Schedule::daily()->runInBackground()->group(function () {
    Schedule::command('command-one');

    // Reset to '* * * * *' and then set to `hourly`
    Schedule::command('command-two')->resetFrequency()->hourly();

    // Reset for the group
    Schedule::resetFrequency()->group(function () {
        Schedule::command('command-three')->everyMinute();
        Schedule::command('command-four')->twiceDaily();
    });
});

Looking forward to your feedback! Thanks for all the hard work 🫰.

@taylorotwell taylorotwell merged commit cfa26fb into laravel:11.x Nov 25, 2024
38 checks passed
@istiak-tridip istiak-tridip deleted the refactor-schedule_group branch November 27, 2024 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants