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

[12.x] Make method repeatEvery public in Sub-Minute Scheduled Tasks #50841

Closed
wants to merge 1 commit into from
Closed

Conversation

decadence
Copy link
Contributor

@decadence decadence commented Mar 29, 2024

Right now there is no way to use full power of Sub-Minute Scheduled Tasks because repeatEvery method is protected and you can't set task to repeat every 3, 4, 6, 12 seconds. Moreover you can't pass dynamic number of seconds to schedule task.

My use case: I need to request some API every 3 seconds so everyTwoSeconds is too often and everyFiveSeconds is too rarely.

Although repeatSeconds property is public so we can do:

$event = Schedule::command(Indicators::class)->runInBackground();
$event->repeatSeconds = 3;
$event->everyMinute();

Which is obviously not a Laravel way to do things. Now only this methods are available:

everySecond
everyTwoSeconds
everyFiveSeconds
everyTenSeconds
everyFifteenSeconds
everyTwentySeconds
everyThirtySeconds

After this change we can call:

Schedule::command(Indicators::class)->repeatEvery(3);

Target is master because this is breaking change if someone inherits Illuminate/Console/Scheduling/Event class.

@driesvints
Copy link
Member

Maybe create a new repeatEverySeconds() method so it can go into 11.x?

@decadence
Copy link
Contributor Author

@driesvints Thanks, I thought about it. I would also prefer to have this method in Laravel 11 but I don't know which way is more preferable for your team. Let's see what Taylor thinks about it.

@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If possible, please consider releasing your code as a package so that the community can still take advantage of your contributions!

If you feel absolutely certain that this code corrects a bug in the framework, please "@" mention me in a follow-up comment with further explanation so that GitHub will send me a notification of your response.

@decadence decadence deleted the patch-2 branch March 29, 2024 14:21
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