vardius / go-api-boilerplate

Go Server/API boilerplate using best practices DDD CQRS ES gRPC
https://go-api-boilerplate.local
MIT License
929 stars 135 forks source link

Returning data through the command bus #103

Closed SDPyle closed 2 years ago

SDPyle commented 2 years ago

Hey brother! I want to first thank you for this awesome boilerplate. It's helped me immensely in starting my ES project. You are awesome!

I hope this isn't too naive a question (I've been working with golang for maybe 5 months or so), but I'm trying to return data to the user upon successful command executions (particularly an EventStoreDB commit position and sometimes the ID of a new aggregate root), and I can't seem to figure out how to return data to the user once it's been published to the command bus through the dispatch handler. I can figure out how to send errors, but if there's no error, how can I return a 200 with something like

{
  "id":5849
}

Perhaps I'm just missing something..

vardius commented 2 years ago

Hi @SDPyle sorry for late reply, I just noticed the issue. With the correct setup the flow is meant to be optimistic, which means that you return response to the user before event handler fires.

SDPyle commented 2 years ago

Thank you sir!