Skip to content

Commit

Permalink
Merge branch 'queueable' into 11.x
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jul 16, 2024
2 parents 0a0ab0c + 98c4394 commit ab0d4c5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 32 deletions.
2 changes: 1 addition & 1 deletion context.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ When the job is dispatched, any information currently stored in the context is c
```php
class ProcessPodcast implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Queueable;

// ...

Expand Down
9 changes: 3 additions & 6 deletions horizon.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ Alternatively, the job you wish to silence can implement the `Laravel\Horizon\Co

class ProcessPodcast implements ShouldQueue, Silenced
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Queueable;

// ...
}
Expand Down Expand Up @@ -307,15 +307,12 @@ Horizon allows you to assign “tags” to jobs, including mailables, broadcast
namespace App\Jobs;

use App\Models\Video;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Queue\Queueable;

class RenderVideo implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Queueable;

/**
* Create a new job instance.
Expand Down
36 changes: 11 additions & 25 deletions queues.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,12 @@ Job classes are very simple, normally containing only a `handle` method that is

use App\Models\Podcast;
use App\Services\AudioProcessor;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Queue\Queueable;

class ProcessPodcast implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Queueable;

/**
* Create a new job instance.
Expand All @@ -207,7 +204,7 @@ Job classes are very simple, normally containing only a `handle` method that is
}
}

In this example, note that we were able to pass an [Eloquent model](/docs/{{version}}/eloquent) directly into the queued job's constructor. Because of the `SerializesModels` trait that the job is using, Eloquent models and their loaded relationships will be gracefully serialized and unserialized when the job is processing.
In this example, note that we were able to pass an [Eloquent model](/docs/{{version}}/eloquent) directly into the queued job's constructor. Because of the `Queueable` trait that the job is using, Eloquent models and their loaded relationships will be gracefully serialized and unserialized when the job is processing.

If your queued job accepts an Eloquent model in its constructor, only the identifier for the model will be serialized onto the queue. When the job is actually handled, the queue system will automatically re-retrieve the full model instance and its loaded relationships from the database. This approach to model serialization allows for much smaller job payloads to be sent to your queue driver.

Expand Down Expand Up @@ -973,15 +970,12 @@ Alternatively, you may specify the job's queue by calling the `onQueue` method w

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Queue\Queueable;

class ProcessPodcast implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Queueable;

/**
* Create a new job instance.
Expand Down Expand Up @@ -1036,15 +1030,12 @@ Alternatively, you may specify the job's connection by calling the `onConnection

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Queue\Queueable;

class ProcessPodcast implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Queueable;

/**
* Create a new job instance.
Expand Down Expand Up @@ -1277,15 +1268,12 @@ To define a batchable job, you should [create a queueable job](#creating-jobs) a
namespace App\Jobs;

use Illuminate\Bus\Batchable;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Queue\Queueable;

class ImportCsv implements ShouldQueue
{
use Batchable, Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Batchable, Queueable;

/**
* Execute the job.
Expand Down Expand Up @@ -1932,15 +1920,13 @@ When a particular job fails, you may want to send an alert to your users or reve

use App\Models\Podcast;
use App\Services\AudioProcessor;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Queue\Queueable;
use Throwable;

class ProcessPodcast implements ShouldQueue
{
use InteractsWithQueue, Queueable, SerializesModels;
use Queueable;

/**
* Create a new job instance.
Expand Down

0 comments on commit ab0d4c5

Please sign in to comment.