Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for batched jobs #1009

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions config/queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@
],
],

/*
|--------------------------------------------------------------------------
| 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
Expand Down
2 changes: 1 addition & 1 deletion modules/system/console/CreateJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}
';
Expand Down
Original file line number Diff line number Diff line change
@@ -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');
}
}
Loading