Skip to content

Event sourcing: decouple from core#449

Merged
dgafka merged 16 commits intoecotoneframework:mainfrom
jlabedo:event-sourcing/decouple-from-core
Feb 25, 2025
Merged

Event sourcing: decouple from core#449
dgafka merged 16 commits intoecotoneframework:mainfrom
jlabedo:event-sourcing/decouple-from-core

Conversation

@jlabedo
Copy link
Contributor

@jlabedo jlabedo commented Feb 21, 2025

Why is this change proposed?

Decouple event sourcing from core Ecotone aggregate modeling.
The end goal is to push event sourcing related logic into its dedicated package Ecotone\EventSourcing

Description of Changes

Refactoring.
Introduction of AggregateRepository interface which is implemented by EventSourcedRepositoryAdapter and StandardRepositoryAdapter.

Pull Request Contribution Terms

  • I have read and agree to the contribution terms outlined in CONTRIBUTING.

@jlabedo jlabedo requested a review from dgafka February 21, 2025 22:08

use Ecotone\Modelling\AggregateFlow\SaveAggregate\AggregateResolver\ResolvedAggregate;

interface AggregateRepository
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of this interface?
And do you see it as user facing interface or more internal one, where state-stored and es-based will be kept on the userland level?

Copy link
Contributor Author

@jlabedo jlabedo Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This interface is meant to abstract StandardRepository and EventSourcedRepository to avoid any BC. One could directly implement AggregateRepository instead of StandardRepository or EventSourcedRepository.

AggregateRepository is a lower abstraction, owned by the core "Aggregate module".
The idea is that an Aggregate read and store some state (which can be standard or event sourced) and publish events.

EventSourcedRepository is a higher abstraction that makes it easier for another package to implement an event sourced repository. This interface would reside in Ecotone\EventSourcing package. Ecotone core event sourcing package would handle any EventSourcedRepository interface to build an AggregateRepository in Ecotone core.

Actual event sourcing Prooph implementation would then reside in its dedicated package, so another implementation could be easily installed into Ecotone.

I am not sure yet, but the projection logic would reside in core EventSourcing package. It would be able to project any events from an EventSourcedRepository and gap detection and stream position would be managed by Ecotone.

Does it makes sense ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize I did not really answer your question :) I think this interface is more internal as it exposes some low level blocks (ResolvedAggregate). But it may be used by package maintainers to implement new ways of storing aggregates.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oki. Having an another EventSourcedRepo on top of AggregateRepository (when we also have ES and State, which points to this) is a bit unclear to me, but happy to discuss it when the time will come.

But in general I do feel the vibes, so happy to approve when ready.
And having smaller PRs like this make it much easier to review and discuss, so thanks :)

@jlabedo
Copy link
Contributor Author

jlabedo commented Feb 24, 2025

@dgafka , let me try to break AggregateRepositoriesCompilerPass into subcomponents before merging if you agree with the general idea ? The difficulty is to handle the current behavior when there is only one repository of kind available.

@dgafka
Copy link
Member

dgafka commented Feb 24, 2025

@jlabedo oki, let me know when ready

@jlabedo jlabedo requested a review from dgafka February 25, 2025 06:47
use Ecotone\Modelling\BaseEventSourcingConfiguration;

#[ModuleAnnotation]
class EventSourcedRepositoryModule implements AnnotationModule
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we could move it to Ecotone\EventSourcing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we could, but we still need to keep it in core_package list for ecotone lite testing to work now.


public function getModuleExtensions(ServiceConfiguration $serviceConfiguration, array $serviceExtensions): array
{
$baseEventSourcingConfiguration = BaseEventSourcingConfiguration::withDefaults();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add @TODO Ecotone 2.0 to move it EventSourcing package

@dgafka dgafka merged commit 32ed7e7 into ecotoneframework:main Feb 25, 2025
33 checks passed
@jlabedo jlabedo mentioned this pull request Mar 28, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants