Laravel Defibrillator is a deal by Michael Dyrynda that allows you assure that elements of your software should really be running often are carrying out so.
📣 I *really* went off the deep close and now current to you Laravel Defibrillator – a tiny package to assist your application responsibilities retain a typical rhythm.
Reduce your jobs from overpowering your database, queue workers, mail supplier, and additional!https://t.co/7yIqUuyFV8
— Michael Dyrynda 💉💉 (@michaeldyrynda) September 6, 2021
This bundle can help by delaying the including of employment to overcome queue employees when they catch up on a backlog of queue jobs, for example:
Look at a scheduled job that communicates with your application customers on a common interval. This scheduled undertaking queues notifications to your end users based on some situation in your application. In a usual situation, there is a handful of notifications to go out, and they are dispatched with in a number of seconds. But an software mistake causes your software to spiral out of command. Queued notifications back again up, your database is not currently being updated to flag notifications as getting been sent, your mistake tracker floods with exceptions.
And then your scheduled job operates all over again.
Abruptly your queue has tens of countless numbers of pending careers in it and you are trapped in a cycle that you can’t preserve up with.
Here is an case in point from the readme of how you may use this trait to hold an regular rhythm:
5community functionality handle()
7 if ($this->hasAbnormalRhythm())
13 // Standard processing
You can also avoid lagging notifications from becoming despatched if the heartbeat enters an abnormal rhythm:
2public purpose shouldSend(): bool
4 return Cache::get('NotifyUsers')?->isFuture() ?? false
This package deal has reasonable defaults for an interval among normal rhythms, which are customizable when working with the package’s
3public function interval(): int
5 return 30
You can discover more about this package deal, get entire set up guidelines, and watch the supply code on GitHub.