= Taco Cloud v0.0.13

This folder contains the source code for the Taco Cloud sample from Spring in Action, 5th edition, as presented in Chapter 13.

At this time, the code in this folder focuses primarily on the Eureka service registry, an ingredient service, and a client that discovers that ingredient service from Eureka. That is to say that it contains only code relevant to the content in chapter 13, but not the complete Taco Cloud application. At some time in the future I may build out the remainder of the Taco Cloud application as a collection of microservices that register and discover each other through Eureka.

It's also important to note that example code tends to evolve throughout the course of a chapter. Moreover, there are often many different variants of a given piece of code presented. The sample code given here may only represent one such variant or evolution.

== Running Taco Cloud

This folder contains three distinct projects:

 * `service-registry` : The Eureka service registry
 * `ingredient-service` : The ingredient service
 * `ingredient-client` : A client application that discovers the ingredient service from Eureka and consumes its endpoints

You'll need to build and run each of the applications individually. In all cases, you can build the application using Maven like this:

[source,sh]
----
% ./mvnw clean package
----

Once the projects are built, you can run their executable JAR files individually. For example, you can run the service registry like this:

[source,sh]
----
% java -jar target/service-registry-0.0.13-SNAPSHOT.jar
----

The ingredient service can be run like this:

[source,sh]
----
% java -jar target/ingredient-service-0.0.13-SNAPSHOT.jar
----

And the ingredient client can be run like this:

[source,sh]
----
% java -jar target/ingredient-client-0.0.13-SNAPSHOT.jar
----

Once each application has started up, the service registry will be listening on port 8761, the ingredient client will be listening on port 8080, and the ingredient service will be listening on a randomly chosen port.

To see it all in action, open your web browser and navigate to http://localhost:8080 to see a list of ingredients. If you click on an ingredient, you'll be shown an ingredient detail page. The list and the data for each ingredient is ultimately produced by the ingredient service and consumed/presented by the ingredient client.

Note that it may take a few moments for the ingredient service to become fully registered with the service registry so that the ingredient client can find it. If you get errors from the ingredient client application, give it a few moments and refresh the page.

By default, the ingredient service is consumed by a `@LoadBalanced` `RestTemplate`. But the ingredient client project also contains code for consuming the service with `WebClient` and with Feign. These options can be enabled by running the ingredient-client application with either the "webclient" profile or the "feign" profile active. For example, to run the client to use `WebClient`:

[source,sh]
----
% java -jar -Dspring.profiles.active=webclient target/ingredient-client-0.0.13-SNAPSHOT.jar
----

Or, to run it with the Feign-based client:

[source,sh]
----
% java -jar -Dspring.profiles.active=feign target/ingredient-client-0.0.13-SNAPSHOT.jar
----


=== What's missing/broken...

As stated earlier, this folder only contains code directly relevant to the discussion in chapter 13 and does not contain the complete Taco Cloud application. At some future time, I may build out the complete Taco Cloud application as a collection of microservices.
