Closed gquemener closed 4 years ago
Nice, that's a good improvement, a lot of people made exactly that mistake.
On Mon, Dec 9, 2019, 15:16 Gildas Quéméner notifications@github.com wrote:
Not sure if this is compatible with php <7.4
You can view, comment on, or merge this pull request online at:
https://github.com/prooph/pdo-event-store/pull/217 Commit Summary
- Prevents using incompatible persistence strategy
File Changes
- M src/MariaDbEventStore.php https://github.com/prooph/pdo-event-store/pull/217/files#diff-0 (5)
- M src/MySqlEventStore.php https://github.com/prooph/pdo-event-store/pull/217/files#diff-1 (5)
- M src/PersistenceStrategy/MariaDbAggregateStreamStrategy.php https://github.com/prooph/pdo-event-store/pull/217/files#diff-2 (4)
- A src/PersistenceStrategy/MariaDbPersistenceStrategy.php https://github.com/prooph/pdo-event-store/pull/217/files#diff-3 (10)
- M src/PersistenceStrategy/MariaDbSingleStreamStrategy.php https://github.com/prooph/pdo-event-store/pull/217/files#diff-4 (4)
- M src/PersistenceStrategy/MySqlAggregateStreamStrategy.php https://github.com/prooph/pdo-event-store/pull/217/files#diff-5 (4)
- A src/PersistenceStrategy/MySqlPersistenceStrategy.php https://github.com/prooph/pdo-event-store/pull/217/files#diff-6 (10)
- M src/PersistenceStrategy/MySqlSimpleStreamStrategy.php https://github.com/prooph/pdo-event-store/pull/217/files#diff-7 (4)
- M src/PersistenceStrategy/MySqlSingleStreamStrategy.php https://github.com/prooph/pdo-event-store/pull/217/files#diff-8 (4)
- M src/PersistenceStrategy/PostgresAggregateStreamStrategy.php https://github.com/prooph/pdo-event-store/pull/217/files#diff-9 (3)
- A src/PersistenceStrategy/PostgresPersistenceStrategy.php https://github.com/prooph/pdo-event-store/pull/217/files#diff-10 (10)
- M src/PersistenceStrategy/PostgresSimpleStreamStrategy.php https://github.com/prooph/pdo-event-store/pull/217/files#diff-11 (3)
- M src/PersistenceStrategy/PostgresSingleStreamStrategy.php https://github.com/prooph/pdo-event-store/pull/217/files#diff-12 (4)
- M src/PostgresEventStore.php https://github.com/prooph/pdo-event-store/pull/217/files#diff-13 (5)
- M tests/MariaDbEventStoreTest.php https://github.com/prooph/pdo-event-store/pull/217/files#diff-14 (3)
Patch Links:
- https://github.com/prooph/pdo-event-store/pull/217.patch
- https://github.com/prooph/pdo-event-store/pull/217.diff
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/prooph/pdo-event-store/pull/217?email_source=notifications&email_token=AADAJPERWHVVB2N56YU5A7DQX2DOXA5CNFSM4JYOPUT2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4H7E67WQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADAJPCQJC53CYT4TDDBRQLQX2DOXANCNFSM4JYOPUTQ .
Note: Not sure if this is compatible with php <7.4
From a quick glance I have not seen anything incompatible. Any specific concerns?
Note: Not sure if this is compatible with php <7.4
From a quick glance I have not seen anything incompatible. Any specific concerns?
I was thinking about that https://www.php.net/manual/en/migration74.new-features.php#migration74.new-features.core.type-variance, but it's not related to the content of this PR.
Since this has not been released yet, I only noticed this now while testing #221 : The constructor signature change from the generic PersistenceStrategy
to a vendor specific interface itself is a BC break for those using custom persistence strategies (like us :)). Not a big deal and easy to be fixed, but something that should be announced respectively.
Constructor is not part of the interface
On Wed, Feb 26, 2020, 13:12 Fritz Gerneth notifications@github.com wrote:
Since this has not been released yet, I only noticed this now while testing #221 https://github.com/prooph/pdo-event-store/pull/221 : The constructor signature change from the generic PersistenceStrategy to a vendor specific interface itself is a BC break for those using custom persistence strategies (like us :)). Not a big deal and easy to be fixed, but something that should be announced respectively.
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/prooph/pdo-event-store/pull/217?email_source=notifications&email_token=AADAJPCB3WMKWGL2JUTW74DRE2IGNA5CNFSM4JYOPUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENA3KCY#issuecomment-591508747, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADAJPA24CQQ2OHY4RIBHOTRE2IGNANCNFSM4JYOPUTQ .
Constructor is not part of the interface
Agreed. However could you be more specific and point to some code (or add a snippet to your comment), please @fritz-gerneth ? I'd like to fully understand what's the issue here.
In case you missed it, all the 3 new interfaces extends the existing PersistenceStrategy
interface, which will allow you to keep the typehint of your dependenc(ies) with this one, thus preventing a BC break.
EDIT: Ok, I see what's the issue here. Sorry, I went to fast in writing.
As the event store implementation constructors have changed, we indeed have introduced a BC break. As a matter of fact, as stated by @fritz-gerneth, user will need to modify their custom persistence strategy implementation (by implementing the correct interface) in order to successfully inject them in the PDO event store implementations:
- class MyCustomMySqlPersistenceStrategy implements PersistenceStrategy
+ class MyCustomMySqlPersistenceStrategy implements MySqlPersistenceStrategy
{
}
A backward compatible manner would have been to keep the PersistenceStrategy
typehint and check type in the ctor or every time the dependency is required:
final class MySqlEventStore implements PdoEventStore
{
public function create(Stream $stream): void
{
$streamName = $stream->streamName();
$this->addStreamToStreamsTable($stream);
try {
+ if (
+ !$this->persistenceStrategy instanceof MySqlPersistenceStrategy
+ ||
+ (
+ !$this->persistenceStrategy instanceof MySqlSingleStreamStrategy
+ && !$this->persistenceStrategy instanceof MySqlSimpleStreamStrategy
+ && !$this->persistenceStrategy instanceof MySqlAggregateStreamStrategy
+ )
+ ) {
+ throw new \InvalidArgumentException(...);
+ }
$tableName = $this->persistenceStrategy->generateTableName($streamName);
$this->createSchemaFor($tableName);
} catch (RuntimeException $exception) {
...
Quite tedious... I'm not sure what's the way to go here :thinking: Semver would enforce releasing a new major version if we keep the current implementation, wouldn't it?
Yes, that's the issue I found myself in. Not exactly sure how many people use a custom strategy and the change is very small. Strictly folllowing semver would require a new major version indeed. Personally both approaches (keeping, doing the check in the constructor) are fine. My initial concern only was that this should not go unmentioned and at the least be mentioned in the release notes somewhere :)
Puh, I missed the discussion (hadn't much time for OSS end of last year). I was pointed to the BC break introduced in this PR today. event-store v7 is downloaded 400 times / day.
I really don't like to publish any BC breaks even not small ones, when a library is used heavily in production environments (which is the case for prooph event store v7).
We should rollback the changes. They are a good thing to prevent stupid use of persistence strategies. That's fine. But only a major release would allow us to make life better for new users. At the moment we should focus more on existing users, because we have a lot!
What we could do is, we start working on 2.0, but gap detection needs to be included in 1.x
My suggestion:
PR to rollback changes
I can take care of it. WDYT of introducing the interfaces in a BC manner (aka reverting only the event stores ctor signature and adding extra type check)?
Maybe even trigger a deprecate error when a non vendor specific persistence strategy is injected :thinking:
Yes, deprecation error please, but not an exception, otherwise you still have the problem that your custom strategy will no longer work without implementing the new interface
and thank you @gquemener for the PR and taking care of it :+1:
Looks all good to me, only one thing: I'm a little hesitant starting a 2.0 branch and release, when all we have as changes is this persistence strategy thing. For a new major release I would expect a little more than only "cosmetic" changes.
Constructor is not part of the interface
I was writing from phone and didn't realize this in indeed a BC. Sorry for the confusion.
Deprecation error is a good idea 👍
@prolic release fast, release often :D
but yeah, we don't need to release 2.0 soon. The added deprecation warning should already be a good hint for those who use persistence strategy wrong.
But maybe we already have some more topics to tackle in a 2.0 like gap detection enabled by default along with a rewrite of the projections to decrease constructor arguments and better share functionality between query, projection and read model projection.
I'd also like to work on Postgres Notify Support. Not sure if this can be added without BC break to 1.x
Whoever wants to work on those topics, feel free to do so. I can do code reviews but won't have much time coding this.
I'll prepare 1.12 release this weekend.
@codeliner anything else you need to do before this can get merged?
On Fri, Feb 28, 2020, 14:44 Alexander Miertsch notifications@github.com wrote:
@prolic https://github.com/prolic release fast, release often :D
but yeah, we don't need to release 2.0 soon. The added deprecation warning should already be a good hint for those who use persistence strategy wrong.
But maybe we already have some more topics to tackle in a 2.0 like gap detection enabled by default along with a rewrite of the projections to decrease constructor arguments and better share functionality between query, projection and read model projection.
I'd also like to work on Postgres Notify Support. Not sure if this can be added without BC break to 1.x
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/prooph/pdo-event-store/pull/217?email_source=notifications&email_token=AADAJPGQ5XYVONKBXYJJ74TRFFERTA5CNFSM4JYOPUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENJQ7WY#issuecomment-592646107, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADAJPGJMD64ZBXPGTB2GWLRFFERTANCNFSM4JYOPUTQ .
Currently, configuring a MariaDB PersistenceStrategy within a PostgresEventStore will not trigger PHP type check. The result will most likely be the db server complaining about a wrong syntax (in the best case).
This PR prevents mixing persistence strategies and event store implementations.
Note: Not sure if this is compatible with php <7.4