›
byrcsc/laravel-assignment · 1.x
The package ships one command, which expires overdue offers and flushes the queue.
php artisan assignment:tickThe command advances expired assignment offers and flushes the assignment queue. It takes no arguments and no options.
Expired 3 offer(s) and assigned 1 queued item(s).The command always exits 0. A run with nothing to do reports zeros.
offered and whose
expires_at has passed. It reads them in batches of 100. For each one, the
command ends the row with reason expired, dispatches OfferExpired, and
advances its cascade to the next candidate.The order matters. If an offer exhausts its cascade during step 1, the engine queues the assignable. Step 2 can pick it up in the same run with a fresh cascade.
// routes/console.php
use Illuminate\Support\Facades\Schedule;
Schedule::command('assignment:tick')->everyMinute();Every minute is a sensible default. Correctness does not depend on the cadence. An overdue offer stops holding its slot at its timestamp, whether or not the command has run. The cadence controls how long a declined or expired offer waits before its cascade moves on.
On a busy installation, add withoutOverlapping() so a new run does not start
while a slow run is still going. Concurrent runs are safe either way, because
expiry and the flush both claim rows before they act on them.
Schedule::command('assignment:tick')
->everyMinute()
->withoutOverlapping();You can run the flush half on its own:
use ByRcsc\LaravelAssignment\Facades\Assignment;
Assignment::flushQueue();
Assignment::flushQueue(Callout::class);The expiry half has no public entry point other than this command, so schedule
assignment:tick when you want expiry processed.
Split them when you flush on your own domain events, such as a crew becoming available. You can then sweep expiry on a schedule without the immediate re-offer that a combined run can produce.
make:class.