Laravel SafeDispatcher dispatches your Queue Jobs in a safer & recoverable way.
MIT License
For Laravel, it has the Queues feature, all cool and easy to use, right?
But what if it fails to dispatch a job? Then you have no idea for:
Then it will cost you a lot of time to check the log, sentry issues, create retry command,... Awful, IKR?
Worries no more, SafeDispatcher got your back. Check out how it works below.
Documentation:
SafeDispatcher will:
SQSException
(size > 256kb), then you can resend using redis/database driver.composer require shipsaas/safe-dispatcher
use SaasSafeDispatcher\Bus\SafeDispatcher;
class RegisterService
{
public function __construct(public SafeDispatcher $dispatcher) {}
public function register(): void
{
$user = User::create();
$job = new SendEmailToRegisteredUser($user);
$this->dispatcher->dispatch($job);
}
}
use SaasSafeDispatcher\Traits\SafeDispatchable;
class SendEmailToRegisteredUser implements ShouldQueue
{
use SafeDispatchable;
}
SendEmailToRegisteredUser::safeDispatch($user);
safeDispatch(new SendEmailToRegisteredUser($user));
safeDispatch(() => echo('Hello'));
safeDispatchSync(new SendEmailToRegisteredUser($user));
use SaasSafeDispatcher\Services\SafeQueue;
SafeQueue::prepareFor(new Job())
->push('high'); # Push to "high" queue name
Learn more Cover Queue Facade
::safeDispatch
and after finish your job, dispatch another,...sync
Queue as a Queue Msg.
SafeDispatcher is not only have normal Unit Testing but also Integration Test (interacting with MySQL for DB and Redis for Queue).
We're planning to add other queue drivers too (database or SQS).
To run the test, hit this:
composer test
Join me
Thank you, please give it a to support the project.
Don't forget to share with your friends & colleagues
Copyright by ShipSaaS 2023 - Under MIT License.