-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
After first polling projection, module stops registering (#142)
After first polling projection, module stops registering and other polling were not registered anymore. Resolves #141
- Loading branch information
1 parent
bfe7874
commit 0319d14
Showing
4 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/PdoEventSourcing/tests/Fixture/ProductsProjection/Products.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Test\Ecotone\EventSourcing\Fixture\ProductsProjection; | ||
|
||
use Ecotone\EventSourcing\Attribute\Projection; | ||
use Ecotone\Modelling\Attribute\EventHandler; | ||
use Ecotone\Modelling\Attribute\QueryHandler; | ||
use Test\Ecotone\EventSourcing\Fixture\Basket\Basket; | ||
use Test\Ecotone\EventSourcing\Fixture\Basket\Event\ProductWasAddedToBasket; | ||
|
||
#[Projection(self::PROJECTION_NAME, Basket::BASKET_STREAM)] | ||
final class Products | ||
{ | ||
public const PROJECTION_NAME = 'products'; | ||
private array $products = []; | ||
|
||
#[EventHandler(ProductWasAddedToBasket::EVENT_NAME)] | ||
public function when(ProductWasAddedToBasket $event): void | ||
{ | ||
if (array_key_exists($event->getProductName(), $this->products)) { | ||
++$this->products[$event->getProductName()]; | ||
} | ||
$this->products[$event->getProductName()] = 1; | ||
} | ||
|
||
#[QueryHandler('getALlProducts')] | ||
public function getAllProducts(): array | ||
{ | ||
return $this->products; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
packages/PdoEventSourcing/tests/Fixture/ProductsProjection/ProductsConfiguration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Test\Ecotone\EventSourcing\Fixture\ProductsProjection; | ||
|
||
use Ecotone\EventSourcing\ProjectionRunningConfiguration; | ||
use Ecotone\Messaging\Attribute\ServiceContext; | ||
use Ecotone\Messaging\Endpoint\PollingMetadata; | ||
|
||
final class ProductsConfiguration | ||
{ | ||
#[ServiceContext] | ||
public function setMaximumOneRunForProjections(): PollingMetadata | ||
{ | ||
return PollingMetadata::create(Products::PROJECTION_NAME) | ||
->setExecutionAmountLimit(3) | ||
->setExecutionTimeLimitInMilliseconds(300); | ||
} | ||
|
||
#[ServiceContext] | ||
public function enablePollingProjection(): ProjectionRunningConfiguration | ||
{ | ||
return ProjectionRunningConfiguration::createPolling(Products::PROJECTION_NAME); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters