Skip to content
Open
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@ Full documentation: https://dereuromark.github.io/cakephp-queue/

## Cronjob based background scheduling
If you are looking for scheduling certain background jobs: This plugin works flawlessly with [QueueScheduler plugin](https://github.com/dereuromark/cakephp-queue-scheduler).

## FORK NOTES
This fork is to add a few features to the original plugin:
- Add a `QueueProcesses.job_type` column and sets it to the job type when a job is created
31 changes: 31 additions & 0 deletions config/Migrations/20191319000002_MigrationQueueRename.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

use Phinx\Migration\AbstractMigration;

class MigrationQueueRename extends AbstractMigration {

/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* @return void
*/
public function change() {
$table = $this->table('queued_jobs');
$table->renameColumn('job_type', 'job_task')
->update();

$table->changeColumn('job_task', 'string', [
'length' => 90,
'null' => false,
'default' => null,
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
])->update();
}

}
1 change: 1 addition & 0 deletions src/Model/Entity/QueuedJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* @property array|null $data
* @property string|null $data_string Virtual property from JsonableBehavior
* @property string|null $job_group
* @property string|null $job_type
* @property string|null $reference
* @property \Cake\I18n\DateTime $created
* @property \Cake\I18n\DateTime|null $notbefore
Expand Down
8 changes: 7 additions & 1 deletion src/Model/Table/QueueProcessesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function initialize(array $config): void {

$this->addBehavior('Timestamp');


$this->hasOne('CurrentQueuedJobs', [
'className' => 'Queue.QueuedJobs',
'foreignKey' => 'workerkey',
Expand Down Expand Up @@ -108,6 +109,9 @@ public function validationDefault(Validator $validator): Validator {
'message' => 'Too many workers running. Check your `Queue.maxworkers` config.',
]);

$validator->notEmptyString('job_type');


return $validator;
}

Expand Down Expand Up @@ -144,10 +148,11 @@ public function findActive(): SelectQuery {
/**
* @param string $pid
* @param string $key
* @param string $jobType
*
* @return int
*/
public function add(string $pid, string $key): int {
public function add(string $pid, string $key, string $jobType): int {
$server = $this->buildServerString();

// Evict any stale row holding our (pid, server) slot. Common after
Expand All @@ -167,6 +172,7 @@ public function add(string $pid, string $key): int {
'pid' => $pid,
'server' => $server,
'workerkey' => $key,
'job_type' => $jobType
];

$queueProcess = $this->newEntity($data);
Expand Down
Loading