diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1e4d01dc..90d75aec 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,7 +30,7 @@ jobs: secrets: codecovToken: ${{ secrets.CODECOV_TOKEN }} with: - ini-values: pcov.directory=$GITHUB_WORKSPACE, pcov.exclude=#^(?!($GITHUB_WORKSPACE/config/|$GITHUB_WORKSPACE/src/)).*# + ini-values: pcov.directory=%GITHUB_WORKSPACE%, pcov.exclude=#^(?!(%GITHUB_WORKSPACE%/config/|%GITHUB_WORKSPACE%/src/)).*# os: >- ['ubuntu-latest'] php: >- diff --git a/docs/guide/en/queue-names-advanced.md b/docs/guide/en/queue-names-advanced.md index f67ce37b..0734118e 100644 --- a/docs/guide/en/queue-names-advanced.md +++ b/docs/guide/en/queue-names-advanced.md @@ -14,7 +14,7 @@ Providers translate a queue name into the capability the caller needs: Both lookup methods accept a string or `BackedEnum`. They throw `QueueNotFoundException` when the name is unknown or does not have the requested role. This separation prevents a producer-only queue from accidentally being used by a worker, and vice versa. -The default name is `QueueProducerProviderInterface::DEFAULT_QUEUE` (also available from `QueueConsumerProviderInterface`), whose value is `yii-queue`. +The default name is `DefaultQueue::NAME`, whose value is `yii-queue`. ## Role-map configuration diff --git a/docs/guide/en/queue-names.md b/docs/guide/en/queue-names.md index 33ee34d2..1895c3bc 100644 --- a/docs/guide/en/queue-names.md +++ b/docs/guide/en/queue-names.md @@ -6,7 +6,7 @@ A *queue name* is a logical identifier for independently configured producer and - Use `QueueProducerProviderInterface` to obtain a named producer with `getProducer()`. - Use `QueueConsumerProviderInterface` to obtain a named consumer with `getConsumer()`; console commands use this provider. -The default name is `QueueProducerProviderInterface::DEFAULT_QUEUE` (also available from `QueueConsumerProviderInterface`) and is `yii-queue`. +The default name is `DefaultQueue::NAME`, whose value is `yii-queue`. ## When to use named queues @@ -18,7 +18,7 @@ Named queues use a strict role map under `yiisoft/queue.queues`. Each name must ```php use Yiisoft\Queue\Adapter\AdapterInterface; -use Yiisoft\Queue\Provider\QueueProducerProviderInterface; +use Yiisoft\Queue\DefaultQueue; use Yiisoft\Queue\QueueConsumer; use Yiisoft\Queue\AsyncQueueProducer; @@ -26,7 +26,7 @@ return [ 'yiisoft/queue' => [ 'queues' => [ // A queue with both capabilities. - QueueProducerProviderInterface::DEFAULT_QUEUE => [ + DefaultQueue::NAME => [ 'producer' => ['class' => AsyncQueueProducer::class, '__construct()' => ['adapter' => AdapterInterface::class]], 'consumer' => ['class' => QueueConsumer::class, '__construct()' => ['adapter' => AdapterInterface::class]], ], diff --git a/src/AsyncQueueProducer.php b/src/AsyncQueueProducer.php index 22e785dc..38c8a3c0 100644 --- a/src/AsyncQueueProducer.php +++ b/src/AsyncQueueProducer.php @@ -12,7 +12,6 @@ use Yiisoft\Queue\Middleware\Push\AdapterPushHandler; use Yiisoft\Queue\Middleware\Push\PushMiddlewareConfig; use Yiisoft\Queue\Middleware\Push\PushMiddlewareDispatcher; -use Yiisoft\Queue\Provider\QueueProducerProviderInterface; /** * Produces messages for one logical queue, pushing them to an adapter-backed broker. @@ -29,7 +28,7 @@ public function __construct( private readonly LoggerInterface $logger, PushMiddlewareConfig $middlewareConfig, private readonly AdapterInterface $adapter, - string|BackedEnum $name = QueueProducerProviderInterface::DEFAULT_QUEUE, + string|BackedEnum $name = DefaultQueue::NAME, array $middlewareDefinitions = [], ) { $this->name = StringNormalizer::normalize($name); diff --git a/src/Command/ListenCommand.php b/src/Command/ListenCommand.php index e87a988a..14b9e04c 100644 --- a/src/Command/ListenCommand.php +++ b/src/Command/ListenCommand.php @@ -9,6 +9,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Yiisoft\Queue\DefaultQueue; use Yiisoft\Queue\Provider\QueueConsumerProviderInterface; #[AsCommand( @@ -29,7 +30,7 @@ public function configure(): void 'queue', InputArgument::OPTIONAL, 'Queue name to connect to', - QueueConsumerProviderInterface::DEFAULT_QUEUE, + DefaultQueue::NAME, ); } diff --git a/src/DefaultQueue.php b/src/DefaultQueue.php new file mode 100644 index 00000000..07eb52a1 --- /dev/null +++ b/src/DefaultQueue.php @@ -0,0 +1,13 @@ +name = StringNormalizer::normalize($name); } diff --git a/src/SyncQueueProducer.php b/src/SyncQueueProducer.php index dcfdde5c..53315f9a 100644 --- a/src/SyncQueueProducer.php +++ b/src/SyncQueueProducer.php @@ -10,7 +10,6 @@ use Yiisoft\Queue\Middleware\Push\PushMiddlewareConfig; use Yiisoft\Queue\Middleware\Push\PushMiddlewareDispatcher; use Yiisoft\Queue\Middleware\Push\SynchronousPushHandler; -use Yiisoft\Queue\Provider\QueueProducerProviderInterface; use Yiisoft\Queue\Worker\WorkerInterface; /** @@ -28,7 +27,7 @@ public function __construct( private readonly LoggerInterface $logger, PushMiddlewareConfig $middlewareConfig, WorkerInterface $worker, - string|BackedEnum $name = QueueProducerProviderInterface::DEFAULT_QUEUE, + string|BackedEnum $name = DefaultQueue::NAME, array $middlewareDefinitions = [], ) { $this->name = StringNormalizer::normalize($name); diff --git a/tests/TestCase.php b/tests/TestCase.php index 765f5dc9..8f597663 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -10,11 +10,11 @@ use Psr\Log\NullLogger; use RuntimeException; use Yiisoft\Injector\Injector; -use Yiisoft\Queue\Provider\QueueProducerProviderInterface; use Yiisoft\Test\Support\Container\SimpleContainer; use Yiisoft\Queue\Adapter\AdapterInterface; use Yiisoft\Queue\Cli\LoopInterface; use Yiisoft\Queue\Cli\SimpleLoop; +use Yiisoft\Queue\DefaultQueue; use Yiisoft\Queue\Middleware\CallableFactory; use Yiisoft\Queue\Middleware\Consume\ConsumeMiddlewareDispatcher; use Yiisoft\Queue\Middleware\Consume\ConsumeMiddlewareFactory; @@ -93,7 +93,7 @@ protected function getContainer(): ContainerInterface protected function createQueue( ?AdapterInterface $adapter = null, - string|BackedEnum $name = QueueProducerProviderInterface::DEFAULT_QUEUE, + string|BackedEnum $name = DefaultQueue::NAME, ): QueueProducerInterface { return $adapter === null ? new SyncQueueProducer( diff --git a/tests/Unit/Command/RunCommandTest.php b/tests/Unit/Command/RunCommandTest.php index 9c5005a3..133cdd83 100644 --- a/tests/Unit/Command/RunCommandTest.php +++ b/tests/Unit/Command/RunCommandTest.php @@ -8,8 +8,8 @@ use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Output\OutputInterface; use Yiisoft\Queue\Command\RunCommand; +use Yiisoft\Queue\DefaultQueue; use Yiisoft\Queue\Provider\PredefinedQueueProvider; -use Yiisoft\Queue\Provider\QueueConsumerProviderInterface; use Yiisoft\Queue\QueueConsumerInterface; use Yiisoft\Queue\Stubs\StubQueueProducer; @@ -32,7 +32,7 @@ public function testDefaultRunSkipsProducerOnlyQueues(): void $consumer->expects($this->once())->method('run')->willReturn(0); $command = new RunCommand(new PredefinedQueueProvider([ 'producer' => ['producer' => new StubQueueProducer()], - QueueConsumerProviderInterface::DEFAULT_QUEUE => ['consumer' => $consumer], + DefaultQueue::NAME => ['consumer' => $consumer], ])); self::assertSame(0, $command->run(new StringInput(''), $this->createMock(OutputInterface::class))); }