A dummy pet store to play with Spring Boot and Spring Cloud frameworks
Features:
- Jetty server instead of the default one used by spring boot (tomcat)
- Database Access using an in-memory embeded data base (H2DB via a JPA repository implementation)
- Data Caching using the default spring cache storage (ConcurrentHashMap)
- Distributed configuration using Spring Cloud Config Server and Client
- Spring Cloud Config server source is a git repo (config files by profile in this-repo/config)
A distributed config server for the petstore inventory app
cd config-server/
gradle build
java -jar build/libs/config-0.0.1-SNAPSHOT.jar
A dummy petstore that lets you add/update/delete pets to the inventory, find them by type, or list them all
cd petstore-inventory/
gradle build
java -jar build/libs/inventory-0.0.1-SNAPSHOT.jar
Pet entities are defined in the petstore-inventory project under Pet.java
Entity can be mapped to the following json structure:
{
"id": "1"
"name": "rose",
"type": "dog",
"color": "white"
}
Returns a json collection of all available pets, endpoint is cached.
Returns a json collection of {type} available pets, endpoint is cached.
Receives a json entity (in the request body) defining a new pet, id is autogenerated by the data repository so there is no need to include the id in the object. Clears cache for /find and / endpoints.
Curl example:
curl -X POST -H "Content-Type: application/json" -d '{"name": "rose", "type": "dog", "color": "white"}' localhost:8000/add
Receives a collection of json entities (in the request body) defining a set of new pets, id is autogenerated by the data repository so there is no need to include the ids in the collection. Clears cache for /find and / endpoints.
Curl example:
curl -X POST -H "Content-Type: application/json" -d '[{"name": "jose", "type": "cat", "color": "white"}, {"name": "steve", "type": "dog", "color": "brow"}, {"name": "hector", "type": "snake", "color": "green"}]' localhost:8000/add-bulk
Receives a json entity (in the request body) to modify an existing pet all attributes of the pet should be set, including the id. Clears cache for /find and / endpoints.
Curl example:
curl -X POST -H "Content-Type: application/json" -d '{"id": 1, "name": "rosa", "type": "dog", "color": "white"}' localhost:8000/update
Removes a pet from the inventory by its id. Clears cache for /find and / endpoints.
Curl example:
curl localhost:8000/delete/6
Returns the petstore owner information associated to this petstore inventory. This information is retrieved via the configuration server and is stored in the config/ folder.
There are two files, one per application profile (north and south), that can be changed in the bootstrap.yml of the petstore-inventory app.
Returns owner name from the information stored in the configuration server.
Returns address from the information stored in the configuration server.
Returns phone from the information stored in the configuration server.