Skip to content

feat: Aggregate.evaluate/2 returns {:ok, [events]}#31

Merged
NeilMenne merged 1 commit intomasterfrom
return-event-ids
Sep 23, 2025
Merged

feat: Aggregate.evaluate/2 returns {:ok, [events]}#31
NeilMenne merged 1 commit intomasterfrom
return-event-ids

Conversation

@langmartin
Copy link
Contributor

@langmartin langmartin commented Sep 17, 2025

Sometimes it's nice to update the aggregate state and know on success exactly which events were just applied. In the case that events are large it might be nice to avoid returning them across the process boundary, so this change leaves the existing evaluate behavior as the default. It adds an option to evaluate, return: :events | :state, which returns the events or state on success. Our application displays some events directly in the frontend and would like to broadcast new events only after the transaction creating them has been committed.

@langmartin langmartin self-assigned this Sep 17, 2025
@langmartin langmartin marked this pull request as draft September 17, 2025 21:55
@langmartin langmartin changed the title feat: Aggregate.evaluate returns {:ok, [timestamps]} feat: Aggregate.evaluate_events returns {:ok, [events]} Sep 18, 2025
@langmartin langmartin marked this pull request as ready for review September 22, 2025 20:52
@langmartin langmartin force-pushed the return-event-ids branch 2 times, most recently from 7d808eb to 8073734 Compare September 23, 2025 18:38
- Add the option `evaluate(command, return: :events | :state)` which returns
  events generated by the command, or the aggregate state after the command.
- Keep the default behavio(u)r of evaluate which does not return
  events or state across the process boundary.

This simplifies a caller that wants to use valid events for
applications outside the scope of maestro itself.
@NeilMenne NeilMenne changed the title feat: Aggregate.evaluate_events returns {:ok, [events]} feat: Aggregate.evaluate/2 returns {:ok, [events]} Sep 23, 2025
Copy link
Member

@NeilMenne NeilMenne left a comment

Choose a reason for hiding this comment

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

welcome to the team

@NeilMenne NeilMenne merged commit 1f26f9c into master Sep 23, 2025
7 checks passed
@NeilMenne NeilMenne deleted the return-event-ids branch September 23, 2025 19:21
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