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] Add pingOnSuccessIf & pingOnFailureIf to Schedule handling #53795

Merged
merged 3 commits into from
Dec 8, 2024

Conversation

lucacastelnuovo
Copy link
Contributor

@lucacastelnuovo lucacastelnuovo commented Dec 8, 2024

Currently pingBeforeIf() exists. Which can be used like this:

Schedule::command('backup:run')->hourly()
    ->pingBefore((bool) config('services.ohdear.tasks.backup:run', false), config('services.ohdear.tasks.backup:run') . '/starting')

This PR proposes adding the same functionality to the pingOnSuccess and the pingOnFailure methods. (https://laravel.com/docs/11.x/scheduling#pinging-urls)

This makes it possible to write the following code:

$pingBackupRun = (bool) config('services.ohdear.tasks.backup:run', false);
$pingBackupRunUrl = config('services.ohdear.tasks.backup:run');

Schedule::command('backup:run')->hourly()
    ->pingBeforeIf($pingBackupRun, $pingBackupRunUrl . '/starting')
    ->pingOnSuccessIf($pingBackupRun, $pingBackupRunUrl . '/finished')
    ->pingOnFailureIf($pingBackupRun, $pingBackupRunUrl . '/failed');

This is my first PR to the laravel/framework repo. Let me know if I did something wrong :)

@taylorotwell taylorotwell merged commit bdf11b1 into laravel:11.x Dec 8, 2024
38 checks passed
@zakariaarrid
Copy link

Hi @lucacastelnuovo !
can you check updated doc ?

@lucacastelnuovo
Copy link
Contributor Author

Hi @lucacastelnuovo !

can you check updated doc ?

I'm sorry, I don't understand the question. Could you clarify?

@lucacastelnuovo lucacastelnuovo deleted the patch-1 branch December 8, 2024 16:36
@zakariaarrid
Copy link

Hi @lucacastelnuovo !
can you check updated doc ?

I'm sorry, I don't understand the question. Could you clarify?

I have submitted a pull request for the Laravel documentation regarding your new functions. Kindly review it here.

@lucacastelnuovo
Copy link
Contributor Author

I have submitted a pull request for the Laravel documentation regarding your new functions. Kindly review it here.

Looks great, thank you. I forgot to do it myself.

browner12 pushed a commit to browner12/framework that referenced this pull request Dec 10, 2024
…ravel#53795)

* Add pingOnSuccessIf & pingOnFailureIf

* [fix]: style error

* Update Event.php

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
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.

3 participants