When using the microservice approach to applications, you end up with a lot of servers listening on a variety of IPs, domains, and ports. These IP addresses will vary by environment (staging versus production), and it can be tricky to keep them static for configuration between services. You also want to know when a machine or service is down or unreachable due to a network partition. A network partition occurs when two parts of the network cannot reach each other. For example, if a switch fails between two data centers, then the services within one datacenter cannot reach services in the other datacenter. Consul is a tool that provides a lot of functionality, but here, we'll explore registering services with Consul and querying them from our other services.
How to do it...
These steps cover writing and running your application:
- From your Terminal or console application,createa new directory called~/projects...