Member-only story
NATS Keep-Alive Subscription in Golang
NATS as API Gateway
NATS is indeed a secure, simple, and scalable technology for our microservices platform.
Microservices itself is a huge topic. Talking about NATS implementation on this architectural style can be very broad, so let’s move on to a more detailed case, such as API gateway using NATS.
The idea of this approach is for every incoming request to the API gateway will be directed to destination service via synchronous call of nats.Conn.Request() method. The return value will be used as the response of the particular API call.
We are going to use the request-reply feature of NATS, because of that the destination service needs to subscribe to the NATS server first, only then the particular service will be able to receive messages sent by API gateway.
Pretty straightforward, isn’t it.
High Availability on NATS
HA is a very important topic in microservices. In real life, most of the time, the HA aspect will be handled by the orchestrator.
- On Docker Compose, use the
restart: always