Configuring Consul/Fabio in DShop


#1

As per Dariusz Pawlukiewicz response about this topic, im creating this for other users. Hope it helps.:

The ResEase library (for doing GET requests to microservices) can be configured in 3 different ways depending on the settings provided in the appsettings.json.

  1. By default it simply uses docker service names as a host part of the URL. That’s why you cannot see anything in the Consul.

  2. The second (more advanced) type of configuration for RestEase is using Consul registry for getting the services names from it.

    • This requires all services registration on startup. In order to do this go to the appsettings.json and change flag named “enabled” to true (in the Consul section). Of course this needs to be done in every single service.
    • Besides that you also need to change the “strategy” for RestEase so in the API Gateway’s appsettings.json go to the RestEase and change the value of “loadBalancer” from “” to “consul”. Assuming your services are successfuly registered, the GET request to the API Gateway should now involve Consul Registry. However since the Consul itself is simple Discovery this strategy uses simplified ( @spetz implementation) of load balancing.
  3. If you want to have Round Robin, you should apply third strategy which also involves Fabio.

    • In order to do this, besides “consul” enabled, you need (in every service) to enable fabio registration simply by changing “enable” value in appsettings. After you’re done go once again to API GAteway and change strategy simply by changing “loadBalancer:” from “consul” to “fabio”.

Thanks Dariusz for your response in gitter.