Comments (16)
Thanks @unixslayer , we will try your suggested solution.
In addition @Mattin also suggested this projection command extension:
Indeed it would be nice to configure cap datection via parameter too.
<?php
declare(strict_types=1);
namespace Prooph\ProophessorDo\Projection\Options;
use Prooph\Bundle\EventStore\Projection\ProjectionOptions;
use Prooph\EventStore\Pdo\Projection\GapDetection;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
final class ToDoProjectionOptions implements ProjectionOptions
{
private ParameterBag $parameterBag;
public function __construct(ParameterBag $parameterBag)
{
$this->parameterBag = $parameterBag;
}
public function options(): array
{
return [
'cache_size' => $this->parameterBag->get('projection.cache_size'),
'sleep' => $this->parameterBag->get('projection.sleep'),
'persist_block_size' => $this->parameterBag->get('projection.persist_block_size'),
'lock_timeout_ms' => $this->parameterBag->get('projection.lock_timeout_ms'),
'trigger_pcntl_dispatch' => $this->parameterBag->get('projection.trigger_pcntl_dispatch'),
'update_lock_threshold' => $this->parameterBag->get('projection.update_lock_threshold'),
'gap_detection' => new GapDetection([0, 5, 5, 10, 15, 25, 40, 65, 105]),
];
}
}
from event-store-symfony-bundle.
@webdevilopers gap detection can be defined using projection options as tagged service. However this way defined options must have a tag for each projection separately:
services:
Prooph\ProophessorDo\Projection\Options\ToDoProjectionOptions:
tags:
- { name: prooph_event_store.projection_options, projection_name: projection_1 }
- { name: prooph_event_store.projection_options, projection_name: projection_2 }
What you need is a nice addition 👍🏻 If in a hurry, you can introduce a PR or wait some time for me to figure it out.
from event-store-symfony-bundle.
@darrylhein how about adding support for projector options in the projections yaml config?
from event-store-symfony-bundle.
@danizord I'm guessing you'd need separate nodes in the yaml config for each projection. I like the idea of passing them to the command as it gives you the ability to change on the fly and not have to update the config. But, it would be nice in yaml or other config that it'd remember for you. But maybe it'd be better to have a separate command for each projection if there's a lot of customization needed.
Here's a hacked together version to support the sleep param: https://github.com/xmmedia/starter_symfony_4/blob/master/src/Command/ProjectionRunCommand.php
from event-store-symfony-bundle.
@danizord I'm guessing you'd need separate nodes in the yaml config for each projection.
We already do, under projections
we have a node for each projection.
I like the idea of passing them to the command as it gives you the ability to change on the fly and not have to update the config.
Can't we have both? :)
from event-store-symfony-bundle.
@prolic this issue can probably be closed
from event-store-symfony-bundle.
The OPTION_GAP_DETECTION
has been added. Not sure if it is missing in this bundle currently.
It would be nice to have a configuration for single projections or enable die gap detection globally.
At least the option can be added manually directly to a projection manager:
$gapDetection = new GapDetection();
$projection = $projectionManager->createProjection('test_projection', [
PdoEventStoreProjector::OPTION_GAP_DETECTION => $gapDetection,
]);
from event-store-symfony-bundle.
@unixslayer I just remembered that we talked about the "event sourcing" and "projection" dependencies in the current versions:#
on dev-master dependency for prooph/event-sourcing was dropped.
Currently we still use prooph/event-store-symfony-bundle
^0.8.0 because changing the config would require some work:
*#73 (comment)
Adding projection options in ^0.8.0 will cause:
Unrecognized option "options" under "prooph_event_store.projection_managers.default_projection_manager.projections.account_details".
Available options are "projection", "read_model".
Similar issue w/ the tagged example since the extended class Prooph\Bundle\EventStore\Projection\ProjectionOptions
does not exist.
So I guess there is no other option than updating this bundle?
from event-store-symfony-bundle.
@webdevilopers I think you still should be able to use latest version of this bundle and require prooph/event-sourcing separately
from event-store-symfony-bundle.
Hm, without having to change the config?
And keep the 0.8.0 for event-sourcing
?
from event-store-symfony-bundle.
Ok, got it!
"prooph/event-store-symfony-bundle": "^0.9.1",
Since we're on Symfony 5.1.
We "only" have to replace the repositories e.g. via:
class SomeAggregateRepository extends AggregateRepository
{
public function __construct(EventStore $eventStore)
{
parent::__construct(
$eventStore,
AggregateType::fromAggregateRootClass(SomeAggregate::class),
new AggregateTranslator(),
null,
new StreamName('some_aggregate_stream')
);
}
}
Will give it a try now!
from event-store-symfony-bundle.
Looks promising so far @unixslayer .
Where can I verify that projection options are adapted?
prooph_event_store:
stores:
default:
event_store: Prooph\EventStore\EventStore
projection_managers:
default_projection_manager:
event_store: 'prooph_event_store.default'
connection: '@app.event_store.pdo_connection.pgsql'
projections:
visit_details:
read_model: Acme\Visit\Infrastructure\Projection\MongoVisitDetailsReadModel
projection: Acme\Visit\Infrastructure\Projection\MongoVisitDetailsProjection
options:
- lock_timeout_ms: 666
- sleep: 100000000000
Next I tried a simple dump inside a projector:
final class MongoVisitDetailsProjection implements ReadModelProjection
{
public function project(ReadModelProjector $projector): ReadModelProjector
{dd($projector);
But the result does not use my custom values:
...
-initCallback: null
-handler: null
-handlers: []
-isStopped: false
-currentStreamName: null
-lockTimeoutMs: 1000
-eventCounter: 0
-sleep: 100000
-triggerPcntlSignalDispatch: false
-updateLockThreshold: 0
-gapDetection: null
-query: null
-vendor: "pgsql"
-lastLockUpdate: null
-metadataMatcher: null
}
This happens with 0.9.1. Any ideas?
from event-store-symfony-bundle.
BTW the tagged service works like a charm!
<?php declare(strict_types=1);
namespace Acme\Common\Infrastructure\Prooph\Projection;
use Prooph\Bundle\EventStore\Projection\ProjectionOptions;
use Prooph\EventStore\Pdo\Projection\GapDetection;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
final class GlobalProjectionOptions implements ProjectionOptions
{
private ParameterBagInterface $parameterBag;
public function __construct(ParameterBagInterface $parameterBag)
{
$this->parameterBag = $parameterBag;
}
public function options(): array
{
return [
/*
'cache_size' => $this->parameterBag->get('projection.cache_size'),
'sleep' => $this->parameterBag->get('projection.sleep'),
'persist_block_size' => $this->parameterBag->get('projection.persist_block_size'),
'lock_timeout_ms' => $this->parameterBag->get('projection.lock_timeout_ms'),
'trigger_pcntl_dispatch' => $this->parameterBag->get('projection.trigger_pcntl_dispatch'),
'update_lock_threshold' => $this->parameterBag->get('projection.update_lock_threshold'),
*/
'update_lock_threshold' => 666,
'gap_detection' => new GapDetection([0, 5, 5, 10, 15, 25, 40, 65, 105]),
];
}
}
...
-updateLockThreshold: 666
-gapDetection: Prooph\EventStore\Pdo\Projection\GapDetection {#119
-retryConfig: array:9 [
0 => 0
1 => 5
2 => 5
3 => 10
4 => 15
5 => 25
6 => 40
7 => 65
8 => 105
]
-detectionWindow: null
-retries: 0
}
from event-store-symfony-bundle.
@webdevilopers sorry for late response. I just checked it and looks like options should be adapted properly when defined in central projection configuration as you can see bellow:
from event-store-symfony-bundle.
@webdevilopers I've just released v0.9.3 which allows to define projection options in central configuration (eg. yaml). Please refer to docs example. Take note that both retry_config
and detection_window
are optional for GapDetection
.
from event-store-symfony-bundle.
Thanks for the great work! Will try to check it out in the next days!
from event-store-symfony-bundle.
Related Issues (20)
- Allow service references with a prefix @
- Raise version of symfony dependencies HOT 3
- Deprecated relying on its factory's return-type to define the class of service HOT 2
- How to use SingleStreamStrategy? HOT 6
- Projections defined as services cannot be found HOT 2
- Graceful shutdown on interrupt HOT 14
- Prevent autowiring to malfunction while defining aggregate repositories HOT 1
- Command event-store:projection:names does not use provided limit HOT 2
- Incorrect values on parameter prooph_event_store.projection_managers HOT 1
- ProjectionManagerFactory doesn't handle EventStoreDecorator HOT 1
- How to register event-store plugins such as Metadata enricher HOT 6
- Cannot autowire service when installing the bundle HOT 2
- Repository autowiring doesn't work HOT 3
- Add a --time-limit option for event-store:projection:run command
- Drop dependency to prooph/event-sourcing
- Plugins and Metadata Enrichers are not recognized HOT 50
- Security Warning by dependabot HOT 3
- Deprecated callable reference to self in PHP 8.2 HOT 1
- Symfony 7 support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from event-store-symfony-bundle.