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

Return execution result from command dispatch #92

Closed
JoanZapata opened this issue Oct 10, 2017 · 2 comments
Closed

Return execution result from command dispatch #92

JoanZapata opened this issue Oct 10, 2017 · 2 comments
Labels

Comments

@JoanZapata
Copy link

JoanZapata commented Oct 10, 2017

Router.dispatch/1 doesn't allow to retrieve the events produced by the aggregate in response to the command.

It could either be added as a breaking change to unify the API:

# Would have previously returned :ok
iex> Router.dispatch(command)
{
  :ok, 
  %ExecutionResult{
    aggregate_uuid: aggregate_uuid, 
    aggregate_version: aggregate_version, 
    events: events,
    metadata: metadata,
  }
}

Or as a non-breaking change, using a new option

iex> Router.dispatch(command)
:ok

iex> Router.dispatch(command, include_aggregate_version: true)
{:ok, aggregate_version}

iex> Router.dispatch(command, include_execution_result: true)
{
  :ok, 
  %ExecutionResult{
    aggregate_uuid: aggregate_uuid, 
    aggregate_version: aggregate_version, 
    events: events,
    metadata: metadata,
  }
}
@slashdotdash slashdotdash changed the title Return metadata from dispatch Return execution result from dispatch Oct 11, 2017
@slashdotdash slashdotdash changed the title Return execution result from dispatch Return execution result from command dispatch Oct 11, 2017
@JoanZapata
Copy link
Author

@slashdotdash If that's ok, I'll make a naive implementation of the second option and submit a pull request.

@slashdotdash
Copy link
Member

Yes, I think extending the API with the non-breaking change is preferable for now. Good luck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants