Skip to content

Commit d798ba9

Browse files
Cleanup Queue (#318)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 1a9f5e2 commit d798ba9

1 file changed

Lines changed: 7 additions & 18 deletions

File tree

src/Queue.php

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Yiisoft\Queue\Cli\LoopInterface;
1111
use Yiisoft\Queue\Message\MessageInterface;
1212
use Yiisoft\Queue\Middleware\Push\AdapterPushHandler;
13-
use Yiisoft\Queue\Middleware\Push\PushHandlerInterface;
1413
use Yiisoft\Queue\Middleware\Push\PushMiddlewareConfig;
1514
use Yiisoft\Queue\Middleware\Push\PushMiddlewareDispatcher;
1615
use Yiisoft\Queue\Middleware\Push\SynchronousPushHandler;
@@ -48,16 +47,13 @@ public function __construct(
4847
mixed ...$middlewareDefinitions,
4948
) {
5049
$this->name = StringNormalizer::normalize($name);
51-
$this->dispatcher = (new PushMiddlewareDispatcher(
52-
$middlewareConfig->middlewareFactory,
53-
$middlewareConfig->commonMiddlewareDefinitions,
54-
$this->createFinalPushHandler(),
55-
))->withMiddlewaresAdded($middlewareDefinitions);
56-
}
57-
58-
public function __clone()
59-
{
60-
$this->dispatcher = $this->dispatcher->withFinishHandler($this->createFinalPushHandler());
50+
$this->dispatcher = new PushMiddlewareDispatcher(
51+
middlewareFactory: $middlewareConfig->middlewareFactory,
52+
middlewareDefinitions: [...$middlewareConfig->commonMiddlewareDefinitions, ...$middlewareDefinitions],
53+
finishHandler: $this->isSynchronous()
54+
? new SynchronousPushHandler($this->worker, $this)
55+
: new AdapterPushHandler($this->adapter),
56+
);
6157
}
6258

6359
public function getName(): string
@@ -157,13 +153,6 @@ private function handle(MessageInterface $message): bool
157153
return $this->loop->canContinue();
158154
}
159155

160-
private function createFinalPushHandler(): PushHandlerInterface
161-
{
162-
return $this->isSynchronous()
163-
? new SynchronousPushHandler($this->worker, $this)
164-
: new AdapterPushHandler($this->adapter);
165-
}
166-
167156
/**
168157
* @psalm-assert-if-false !null $this->adapter
169158
*/

0 commit comments

Comments
 (0)