Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggregate event streams #664

Open
adriano-di-giovanni opened this issue Jun 4, 2021 · 1 comment
Open

Aggregate event streams #664

adriano-di-giovanni opened this issue Jun 4, 2021 · 1 comment

Comments

@adriano-di-giovanni
Copy link

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Persisting events using external stores such as Event Store happens by appending them to a stream. The stream groups all events related to a particular instance of an aggregate root. The stream name usually is <AggregateRoot>-<id>.

At the moment, the stream name/id information has to be bundled with the event.

Expected behavior

It would be great to introduce the concept of stream name/id at the AggregateRoot level

export abstract class AggregateRoot<EventBase extends IEvent = IEvent> {
  // ...
  protected get streamId(): string {
    return void 0
  }

  publish<T extends EventBase = EventBase>(event: T, streamId?: string) {}
}

Such change would also impact

  • the IEventBus and IEventPublisher interfaces
  • the EventPublisher

If streamId is optional, the change is non-breaking.

@redaLaanait
Copy link

redaLaanait commented Oct 17, 2022

Wrapping the event and passing the streamId as metadata to the event envelope (which also extends IEvent) may solve the problem.

the event handler can be decorated as follow:

@EventsHandler(Envelope<OriginalEvent>)

(just started looking into nestjs and CQRS module... hope I'm not messing up)

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

No branches or pull requests

2 participants