So, I have to handle sync call in async way.
My go microservice using gin context receives request on /req endpoint, and I have to send it to some other microservice say B, after performing validations, which will give me acknowledgement that it received the request.
Upon receiving request B will perform operation and respond to my microservice at /resp endpoint.
Now the response which came from B has to be sent back to the service which sent request on /req.
Note: I have to write back response on same context from which I initially got request at /req.
My implementation: I was able to achieve this using channels and sync map but with this approach, there is a major scalability issue, if I scale my service to multiple instances, response from B can come on any instance, and that instance will not be having that channel and map, as it is specific to particular instance.
So I need a solution, considering
- Session affinity cannot be used.
- initial service cannot be changed, so I have to handle this.
Please let me know a solution which can help.
Amrit Singh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.