|
10 | 10 | use Yiisoft\Queue\Cli\LoopInterface; |
11 | 11 | use Yiisoft\Queue\Message\MessageInterface; |
12 | 12 | use Yiisoft\Queue\Middleware\Push\AdapterPushHandler; |
13 | | -use Yiisoft\Queue\Middleware\Push\PushHandlerInterface; |
14 | 13 | use Yiisoft\Queue\Middleware\Push\PushMiddlewareConfig; |
15 | 14 | use Yiisoft\Queue\Middleware\Push\PushMiddlewareDispatcher; |
16 | 15 | use Yiisoft\Queue\Middleware\Push\SynchronousPushHandler; |
@@ -48,16 +47,13 @@ public function __construct( |
48 | 47 | mixed ...$middlewareDefinitions, |
49 | 48 | ) { |
50 | 49 | $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 | + ); |
61 | 57 | } |
62 | 58 |
|
63 | 59 | public function getName(): string |
@@ -157,13 +153,6 @@ private function handle(MessageInterface $message): bool |
157 | 153 | return $this->loop->canContinue(); |
158 | 154 | } |
159 | 155 |
|
160 | | - private function createFinalPushHandler(): PushHandlerInterface |
161 | | - { |
162 | | - return $this->isSynchronous() |
163 | | - ? new SynchronousPushHandler($this->worker, $this) |
164 | | - : new AdapterPushHandler($this->adapter); |
165 | | - } |
166 | | - |
167 | 156 | /** |
168 | 157 | * @psalm-assert-if-false !null $this->adapter |
169 | 158 | */ |
|
0 commit comments