Hi, I have a scenario with the following components:
Controller (a Phoenix one) -> API (GenServer) -> EventBus (GenEvent) -> Worker (GenServer)
The applications are under an umbrella with the web layer, API and Messaging+Worker. For the web layer standpoint, I need to make sure of 2 things:
- API got my request
- job was done
But also for the web layer standpoint, the communication happens with the API only, how the API makes its work, it is an API concern.
One of my initial thoughts was having my API handle_call notifying the Messaging and listen to a message back, to then send the reply to the web layer. But I heard/read that is not good add a receive to listen general messages inside GenServer callbacks.
Other option is handling the worker messages in the API with handle_info, and send a message to the controller, but that will require having a receive to get the message in the controller side, what I don’t know if it is a good approach.
Any suggestions or comments?