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

Merge Push and Consume middlewares #189

Closed
wants to merge 11 commits into from
4 changes: 2 additions & 2 deletions src/Debug/QueueCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace Yiisoft\Queue\Debug;

use Yiisoft\Queue\Middleware\MiddlewareInterface;
use Yiisoft\Yii\Debug\Collector\CollectorTrait;
use Yiisoft\Yii\Debug\Collector\SummaryCollectorInterface;
use Yiisoft\Queue\Enum\JobStatus;
use Yiisoft\Queue\Message\MessageInterface;
use Yiisoft\Queue\Middleware\Push\MiddlewarePushInterface;
use Yiisoft\Queue\QueueInterface;

final class QueueCollector implements SummaryCollectorInterface
Expand Down Expand Up @@ -53,7 +53,7 @@ public function collectStatus(string $id, JobStatus $status): void
public function collectPush(
string $channel,
MessageInterface $message,
string|array|callable|MiddlewarePushInterface ...$middlewareDefinitions,
string|array|callable|MiddlewareInterface ...$middlewareDefinitions,
): void {
if (!$this->isActive()) {
return;
Expand Down
9 changes: 7 additions & 2 deletions src/Debug/QueueDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Yiisoft\Queue\Adapter\AdapterInterface;
use Yiisoft\Queue\Enum\JobStatus;
use Yiisoft\Queue\Message\MessageInterface;
use Yiisoft\Queue\Middleware\Push\MiddlewarePushInterface;
use Yiisoft\Queue\Middleware\MiddlewareInterface;
use Yiisoft\Queue\QueueInterface;

final class QueueDecorator implements QueueInterface
Expand All @@ -28,7 +28,7 @@

public function push(
MessageInterface $message,
string|array|callable|MiddlewarePushInterface ...$middlewareDefinitions
string|array|callable|MiddlewareInterface ...$middlewareDefinitions
): MessageInterface {
$message = $this->queue->push($message, ...$middlewareDefinitions);
$this->collector->collectPush($this->queue->getChannelName(), $message, ...$middlewareDefinitions);
Expand Down Expand Up @@ -61,4 +61,9 @@
$new->queue = $this->queue->withChannelName($channel);
return $new;
}

public function getAdapter(): ?AdapterInterface

Check warning on line 65 in src/Debug/QueueDecorator.php

View check run for this annotation

Codecov / codecov/patch

src/Debug/QueueDecorator.php#L65

Added line #L65 was not covered by tests
{
return $this->queue->getAdapter();

Check warning on line 67 in src/Debug/QueueDecorator.php

View check run for this annotation

Codecov / codecov/patch

src/Debug/QueueDecorator.php#L67

Added line #L67 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

declare(strict_types=1);

namespace Yiisoft\Queue\Middleware\Push;
namespace Yiisoft\Queue\Middleware;

use Yiisoft\Queue\Exception\AdapterConfiguration\AdapterNotConfiguredException;

/**
* @internal
*/
final class AdapterPushHandler implements MessageHandlerPushInterface
final class AdapterHandler implements MessageHandlerInterface
{
public function handlePush(PushRequest $request): PushRequest
public function handle(Request $request): Request
{
if (($adapter = $request->getAdapter()) === null) {
throw new AdapterNotConfiguredException();
Expand Down
100 changes: 0 additions & 100 deletions src/Middleware/Consume/ConsumeMiddlewareDispatcher.php

This file was deleted.

41 changes: 0 additions & 41 deletions src/Middleware/Consume/ConsumeRequest.php

This file was deleted.

10 changes: 0 additions & 10 deletions src/Middleware/Consume/MessageHandlerConsumeInterface.php

This file was deleted.

10 changes: 0 additions & 10 deletions src/Middleware/Consume/MiddlewareConsumeInterface.php

This file was deleted.

75 changes: 0 additions & 75 deletions src/Middleware/Consume/MiddlewareConsumeStack.php

This file was deleted.

Loading
Loading