›
›
›
  1. docs
  2. ›
  3. byrcsc/laravel-assignment
1.x
Browse documentationOpenClose

Getting started

  • Introduction
  • Installation and setup
  • Quick start

Core concepts

  • Assignments and slots
  • Assigning and offering
  • Selection policies
  • Scopes and rotation
  • Profiles
  • The queue
  • Offer cascades

Operations

  • Expiry and scheduling
  • Reading assignments
  • Notifications
  • Events and listeners
  • Concurrency guarantees

Reference

  • Configuration
  • API reference
  • Console commands
  • Exceptions
  • Testing
  • Troubleshooting

Getting started

  • Introduction
  • Installation and setup
  • Quick start

Core concepts

  • Assignments and slots
  • Assigning and offering
  • Selection policies
  • Scopes and rotation
  • Profiles
  • The queue
  • Offer cascades

Operations

  • Expiry and scheduling
  • Reading assignments
  • Notifications
  • Events and listeners
  • Concurrency guarantees

Reference

  • Configuration
  • API reference
  • Console commands
  • Exceptions
  • Testing
  • Troubleshooting

byrcsc/laravel-assignment · 1.x

Console commands.

The package ships one command, which expires overdue offers and flushes the queue.

assignment:tick

php artisan assignment:tick

The 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.

What it does, in order

  1. Expiry. Finds every offer whose status is 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.
  2. Flush. Runs the queue flush across every assignable type, in priority order and then arrival order. The flush deletes entries whose assignable model no longer exists.

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.

Scheduling it

// 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();

Running the halves separately

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.

What the package does not ship

  • A scaffolding command. Profiles are ordinary classes. Create one with make:class.
  • A status command. Read the models directly, as reading assignments shows.
  • A pruning command. Assignment rows are the history, and nothing prunes them.
  • A health check. Publish and migrate, then assign in tinker.

What to read next

  • Expiry and scheduling for TTLs and delayed jobs.
  • The queue for what a flush actually does.
  • Offer cascades for what the expiry step advances.
PreviousAPI referenceNextExceptions
View source

On this page

  1. assignment:tick
  2. What it does, in order
  3. Scheduling it
  4. Running the halves separately
  5. What the package does not ship
  6. What to read next