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

Add BoundedContext abstraction #97

Open
carlos-verdes opened this issue Aug 30, 2024 · 2 comments
Open

Add BoundedContext abstraction #97

carlos-verdes opened this issue Aug 30, 2024 · 2 comments

Comments

@carlos-verdes
Copy link

A single cqrs framework should be able to manage more than one aggregate.

Related with #90

@davegarred
Copy link
Collaborator

That's certainly not the design here.

This is probably more of a naming problem since 'framework' implies you might handle multiple aggregates.

@carlos-verdes
Copy link
Author

Correct me if I'm wrong but let's say I need to implement a Query that read events from 2 different aggregates, from the documentation the simplest Query example looks like this:

struct SimpleLoggingQuery {}

#[async_trait]
impl Query<BankAccount> for SimpleLoggingQuery {
    async fn dispatch(&self, aggregate_id: &str, events: &[EventEnvelope<BankAccount>]) {
        for event in events {
            println!("{}-{}\n{:#?}", aggregate_id, event.sequence, &event.payload);
        }
    }
}

On this example (and others looks similar) I have to provide one aggregate type only, hence I can't handle events from other one.

One option is to create an enum with all aggregates the query is interested in + implement From trait like this:

enum BankQueryInput {
  case BankAccount(BankAccount),
  case TaxesAggregate(TaxesAggregate),
}

impl From<BankAccount> for BankQueryInput {
  ...
}

This way I could write a Query which is interested on bank account movements and tax events.
Let me know if this example has sense to you.

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