Skip to content

Commit 39503a3

Browse files
authored
Move DEFAULT_CHANNEL constant to QueueProviderInterface (#256)
1 parent 5d29243 commit 39503a3

7 files changed

Lines changed: 11 additions & 12 deletions

File tree

config/params.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Yiisoft\Queue\Debug\QueueProviderInterfaceProxy;
1111
use Yiisoft\Queue\Debug\QueueWorkerInterfaceProxy;
1212
use Yiisoft\Queue\Provider\QueueProviderInterface;
13-
use Yiisoft\Queue\QueueInterface;
1413
use Yiisoft\Queue\Worker\WorkerInterface;
1514

1615
return [
@@ -24,7 +23,7 @@
2423
'yiisoft/queue' => [
2524
'handlers' => [],
2625
'channels' => [
27-
QueueInterface::DEFAULT_CHANNEL => AdapterInterface::class,
26+
QueueProviderInterface::DEFAULT_CHANNEL => AdapterInterface::class,
2827
],
2928
'middlewares-push' => [],
3029
'middlewares-consume' => [],

src/Adapter/SynchronousAdapter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Yiisoft\Queue\ChannelNormalizer;
1010
use Yiisoft\Queue\JobStatus;
1111
use Yiisoft\Queue\Message\MessageInterface;
12+
use Yiisoft\Queue\Provider\QueueProviderInterface;
1213
use Yiisoft\Queue\QueueInterface;
1314
use Yiisoft\Queue\Worker\WorkerInterface;
1415
use Yiisoft\Queue\Message\IdEnvelope;
@@ -22,7 +23,7 @@ final class SynchronousAdapter implements AdapterInterface
2223
public function __construct(
2324
private readonly WorkerInterface $worker,
2425
private readonly QueueInterface $queue,
25-
string|BackedEnum $channel = QueueInterface::DEFAULT_CHANNEL,
26+
string|BackedEnum $channel = QueueProviderInterface::DEFAULT_CHANNEL,
2627
) {
2728
$this->channel = ChannelNormalizer::normalize($channel);
2829
}

src/Command/ListenCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Symfony\Component\Console\Input\InputInterface;
1111
use Symfony\Component\Console\Output\OutputInterface;
1212
use Yiisoft\Queue\Provider\QueueProviderInterface;
13-
use Yiisoft\Queue\QueueInterface;
1413

1514
#[AsCommand(
1615
'queue:listen',
@@ -30,7 +29,7 @@ public function configure(): void
3029
'channel',
3130
InputArgument::OPTIONAL,
3231
'Queue channel name to connect to',
33-
QueueInterface::DEFAULT_CHANNEL,
32+
QueueProviderInterface::DEFAULT_CHANNEL,
3433
);
3534
}
3635

src/Provider/QueueProviderInterface.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
*/
1313
interface QueueProviderInterface
1414
{
15+
/** @psalm-suppress MissingClassConstType */
16+
public const DEFAULT_CHANNEL = 'yii-queue';
17+
1518
/**
1619
* Find a queue by channel name and returns it.
1720
*

src/QueueInterface.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111

1212
interface QueueInterface
1313
{
14-
/** @psalm-suppress MissingClassConstType */
15-
public const DEFAULT_CHANNEL = 'yii-queue';
16-
1714
/**
1815
* Pushes a message into the queue.
1916
*

stubs/StubAdapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Yiisoft\Queue\ChannelNormalizer;
1010
use Yiisoft\Queue\JobStatus;
1111
use Yiisoft\Queue\Message\MessageInterface;
12-
use Yiisoft\Queue\QueueInterface;
12+
use Yiisoft\Queue\Provider\QueueProviderInterface;
1313

1414
/**
1515
* Stub adapter that does nothing. Job status is always "done".
@@ -19,7 +19,7 @@ final class StubAdapter implements AdapterInterface
1919
private string $channel;
2020

2121
public function __construct(
22-
string|BackedEnum $channel = QueueInterface::DEFAULT_CHANNEL
22+
string|BackedEnum $channel = QueueProviderInterface::DEFAULT_CHANNEL
2323
) {
2424
$this->channel = ChannelNormalizer::normalize($channel);
2525
}

tests/Unit/Adapter/SynchronousAdapterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Yiisoft\Queue\JobStatus;
1111
use Yiisoft\Queue\Message\IdEnvelope;
1212
use Yiisoft\Queue\Message\Message;
13-
use Yiisoft\Queue\QueueInterface;
13+
use Yiisoft\Queue\Provider\QueueProviderInterface;
1414
use Yiisoft\Queue\Stubs\StubQueue;
1515
use Yiisoft\Queue\Stubs\StubWorker;
1616
use Yiisoft\Queue\Tests\TestCase;
@@ -58,7 +58,7 @@ public function testIdSetting(): void
5858
public function testWithSameChannel(): void
5959
{
6060
$adapter = $this->getAdapter();
61-
self::assertEquals($adapter, $adapter->withChannel(QueueInterface::DEFAULT_CHANNEL));
61+
self::assertEquals($adapter, $adapter->withChannel(QueueProviderInterface::DEFAULT_CHANNEL));
6262
}
6363

6464
public function testWithAnotherChannel(): void

0 commit comments

Comments
 (0)