Lines
0.00%
0 / 5
Functions and Methods
0.00%
0 / 3
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| StateChangeBatchHandler | 0.00% | 0 / 5 | 0.00% | 0 / 3 | 20 | 0.00% | 0 / 1 | |||
| __construct | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| handledMessageClass | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| handle | 0.00% | 0 / 3 | 0.00% | 0 / 1 | 6 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Worker\Message; | |
| 6 | ||
| 7 | use Stewart\Runtime\Dispatch\LocalDispatcher; | |
| 8 | use Stewart\Runtime\Ipc\Message\BrokerMessage; | |
| 9 | use Stewart\Runtime\Ipc\Message\StateChangeBatch; | |
| 10 | use Stewart\Runtime\Worker\StateCacheSync; | |
| 11 | ||
| 12 | /** @implements BrokerMessageHandler<StateChangeBatch> */ | |
| 13 | final readonly class StateChangeBatchHandler implements BrokerMessageHandler | |
| 14 | { | |
| 15 | public function __construct( | |
| 16 | private StateCacheSync $stateCacheSync, | |
| 17 | private LocalDispatcher $dispatcher, | |
| 18 | ) {} | |
| 19 | ||
| 20 | public function handledMessageClass(): string | |
| 21 | { | |
| 22 | return StateChangeBatch::class; | |
| 23 | } | |
| 24 | ||
| 25 | /** @param StateChangeBatch $message */ | |
| 26 | public function handle(BrokerMessage $message): void | |
| 27 | { | |
| 28 | foreach ($message->changes->collection as $change) { | |
| 29 | $this->stateCacheSync->applyStateChange($change); | |
| 30 | } | |
| 31 | ||
| 32 | $this->dispatcher->dispatchStateChanges($message->changes->collection); | |
| 33 | } | |
| 34 | } |