Add support for batched jobs (#1009)

Refs: laravel/framework#32830
This commit is contained in:
Damien MATHIEU 2023-11-15 20:03:30 +01:00 committed by GitHub
parent 539ad66b4b
commit 8010cf1084
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 1 deletions

View File

@ -67,6 +67,22 @@ return [
],
],
/*
|--------------------------------------------------------------------------
| Job Batching
|--------------------------------------------------------------------------
|
| The following options configure the database and table that store job
| batching information. These options can be updated to any database
| connection and table which has been defined by your application.
|
*/
'batching' => [
'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'job_batches',
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs

View File

@ -15,7 +15,7 @@ class CreateJob extends BaseScaffoldCommand
protected $signature = 'create:job
{plugin : The name of the plugin. <info>(eg: Winter.Blog)</info>}
{name : The name of the job class to generate. <info>(eg: ImportPosts)</info>}
{--s|sync : Overwrite existing files with generated files.}
{--s|sync : Indicates that job should be synchronous.}
{--f|force : Overwrite existing files with generated files.}
{--uninspiring : Disable inspirational quotes}
';

View File

@ -0,0 +1,33 @@
<?php
use Winter\Storm\Database\Schema\Blueprint;
use Winter\Storm\Database\Updates\Migration;
class DbJobsBatches extends Migration
{
public function up()
{
Schema::create($this->getTableName(), function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
}
public function down()
{
Schema::dropIfExists($this->getTableName());
}
protected function getTableName()
{
return Config::get('queue.batching.table', 'job_batches');
}
}