Skip to content
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
4 changes: 3 additions & 1 deletion src/Handlers/BaseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ abstract class BaseHandler
protected QueueConfig $config;
protected ?string $priority = null;

abstract public function name(): string;

abstract public function push(string $queue, string $job, array $data): bool;

abstract public function pop(string $queue, array $priorities): ?QueueJob;
Expand Down Expand Up @@ -144,7 +146,7 @@ protected function logFailed(QueueJob $queueJob, Throwable $err): bool
"file: {$err->getFile()}:{$err->getLine()}";

$queueJobFailed = new QueueJobFailed([
'connection' => 'database',
'connection' => $this->name(),
'queue' => $queueJob->queue,
'payload' => $queueJob->payload,
'priority' => $queueJob->priority,
Expand Down
8 changes: 8 additions & 0 deletions src/Handlers/DatabaseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ public function __construct(protected QueueConfig $config)
$this->jobModel = model(QueueJobModel::class, true, $connection);
}

/**
* Name of the handler.
*/
public function name(): string
{
return 'database';
}

/**
* Add job to the queue.
*
Expand Down
8 changes: 8 additions & 0 deletions src/Handlers/PredisHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ public function __construct(protected QueueConfig $config)
}
}

/**
* Name of the handler.
*/
public function name(): string
{
return 'predis';
}

/**
* Add job to the queue.
*/
Expand Down
8 changes: 8 additions & 0 deletions src/Handlers/RedisHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ public function __construct(protected QueueConfig $config)
}
}

/**
* Name of the handler.
*/
public function name(): string
{
return 'redis';
}

/**
* Add job to the queue.
*
Expand Down
4 changes: 2 additions & 2 deletions tests/PredisHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function testFailedAndKeepJob(): void

$this->seeInDatabase('queue_jobs_failed', [
'id' => 2,
'connection' => 'database',
'connection' => 'predis',
'queue' => 'queue1',
]);
}
Expand All @@ -206,7 +206,7 @@ public function testFailedAndDontKeepJob(): void

$this->dontSeeInDatabase('queue_jobs_failed', [
'id' => 2,
'connection' => 'database',
'connection' => 'predis',
'queue' => 'queue1',
]);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/RedisHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function testFailedAndKeepJob(): void

$this->seeInDatabase('queue_jobs_failed', [
'id' => 2,
'connection' => 'database',
'connection' => 'redis',
'queue' => 'queue1',
]);
}
Expand All @@ -187,7 +187,7 @@ public function testFailedAndDontKeepJob(): void

$this->dontSeeInDatabase('queue_jobs_failed', [
'id' => 2,
'connection' => 'database',
'connection' => 'redis',
'queue' => 'queue1',
]);
}
Expand Down