From 5432dc936c8367f8dd3426cc41f4f6de37b11411 Mon Sep 17 00:00:00 2001 From: Fritz Gerneth Date: Mon, 3 Jul 2017 00:21:14 +0200 Subject: [PATCH] Minor code-formating & adjustmnets to follow same style than InMemory projections --- src/Projection/PdoEventStoreProjector.php | 17 ++++++++--------- .../PdoEventStoreReadModelProjector.php | 17 ++++++++--------- tests/Projection/isolated-projection.php | 8 ++++++++ .../isolated-read-model-projection.php | 8 ++++++++ 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/Projection/PdoEventStoreProjector.php b/src/Projection/PdoEventStoreProjector.php index 67ba4533..d4f8b99f 100644 --- a/src/Projection/PdoEventStoreProjector.php +++ b/src/Projection/PdoEventStoreProjector.php @@ -160,6 +160,10 @@ public function __construct( int $sleep, bool $triggerPcntlSignalDispatch = false ) { + if ($triggerPcntlSignalDispatch && ! extension_loaded('pcntl')) { + throw Exception\ExtensionNotLoadedException::withName('pcntl'); + } + $this->eventStore = $eventStore; $this->connection = $connection; $this->name = $name; @@ -170,7 +174,7 @@ public function __construct( $this->persistBlockSize = $persistBlockSize; $this->sleep = $sleep; $this->status = ProjectionStatus::IDLE(); - $this->triggerPcntlSignalDispatch = $triggerPcntlSignalDispatch && extension_loaded('pcntl'); + $this->triggerPcntlSignalDispatch = $triggerPcntlSignalDispatch; while ($eventStore instanceof EventStoreDecorator) { $eventStore = $eventStore->getInnerEventStore(); @@ -505,7 +509,9 @@ public function run(bool $keepRunning = true): void $this->eventCounter = 0; - $this->triggerPcntlSignalDispatch(); + if ($this->triggerPcntlSignalDispatch) { + pcntl_signal_dispatch(); + } switch ($this->fetchRemoteStatus()) { case ProjectionStatus::STOPPING(): @@ -866,11 +872,4 @@ private function prepareStreamPositions(): void $this->streamPositions = array_merge($streamPositions, $this->streamPositions); } - - private function triggerPcntlSignalDispatch(): void - { - if ($this->triggerPcntlSignalDispatch) { - pcntl_signal_dispatch(); - } - } } diff --git a/src/Projection/PdoEventStoreReadModelProjector.php b/src/Projection/PdoEventStoreReadModelProjector.php index 07784dbd..63fc3fc8 100644 --- a/src/Projection/PdoEventStoreReadModelProjector.php +++ b/src/Projection/PdoEventStoreReadModelProjector.php @@ -147,6 +147,10 @@ public function __construct( int $sleep, bool $triggerPcntlSignalDispatch = false ) { + if ($triggerPcntlSignalDispatch && ! extension_loaded('pcntl')) { + throw Exception\ExtensionNotLoadedException::withName('pcntl'); + } + $this->eventStore = $eventStore; $this->connection = $connection; $this->name = $name; @@ -157,7 +161,7 @@ public function __construct( $this->persistBlockSize = $persistBlockSize; $this->sleep = $sleep; $this->status = ProjectionStatus::IDLE(); - $this->triggerPcntlSignalDispatch = $triggerPcntlSignalDispatch && extension_loaded('pcntl'); + $this->triggerPcntlSignalDispatch = $triggerPcntlSignalDispatch; while ($eventStore instanceof EventStoreDecorator) { $eventStore = $eventStore->getInnerEventStore(); @@ -465,7 +469,9 @@ public function run(bool $keepRunning = true): void $this->eventCounter = 0; - $this->triggerPcntlSignalDispatch(); + if ($this->triggerPcntlSignalDispatch) { + pcntl_signal_dispatch(); + } switch ($this->fetchRemoteStatus()) { case ProjectionStatus::STOPPING(): @@ -816,11 +822,4 @@ private function prepareStreamPositions(): void $this->streamPositions = array_merge($streamPositions, $this->streamPositions); } - - private function triggerPcntlSignalDispatch(): void - { - if ($this->triggerPcntlSignalDispatch) { - pcntl_signal_dispatch(); - } - } } diff --git a/tests/Projection/isolated-projection.php b/tests/Projection/isolated-projection.php index 083a87a5..4f50f6b5 100755 --- a/tests/Projection/isolated-projection.php +++ b/tests/Projection/isolated-projection.php @@ -1,4 +1,12 @@ + * (c) 2016-2017 Sascha-Oliver Prolic + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ declare(strict_types=1); diff --git a/tests/Projection/isolated-read-model-projection.php b/tests/Projection/isolated-read-model-projection.php index fa3a554d..54cece7d 100755 --- a/tests/Projection/isolated-read-model-projection.php +++ b/tests/Projection/isolated-read-model-projection.php @@ -1,4 +1,12 @@ + * (c) 2016-2017 Sascha-Oliver Prolic + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ declare(strict_types=1);