REST API service that will manage the campsite reservations
- Requirements
- Maven
- Java 11
- Docker
- Launch a local postgres instance
docker run --name some-postgres -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -d postgres
- Once the db is up, we can run the application
mvn clean package
java -Xmx256m -jar target/campsite-reservations-api-0.0.1-SNAPSHOT.jar
OpenAPI definition can be found at http://localhost:8080/swagger-ui.html while running the api.
Spring REST docs will replace swagger-ui once finished and is available under target/generated-docs
Otherwise here is a summary:
POST /reservation
- Create a reservation
PUT /reservation/{id}
- Modify a reservation by {id}
GET /reservation/{id}
- Get a reservation by {id}
GET /reservation?from={LocalDateTime}&to={LocalDateTime}
- Get all reservations in [from, to] range
- where {LocalDateTime} formatted like: "2021-09-19T12:00:00"
- Get all reservations in [from, to] range
DELETE /reservation/{id}
- Cancel/Delete a reservation by {id}
- Run load test with
mvn gatling:test -Dgatling.simulationClass=campsite.BasicLoadSimulation
- Run concurency test with
mvn gatling:test -Dgatling.simulationClass=campsite.BasicConcurrencySimulation
- Find the results under
/target/gatling/*
- Use Spring Webflux to keep a lower thread count/resource footprint in case we need to scale
- Because we don't have any other service dependency down the chain except the DB
- This will need to be measure in a later performance benchmark with Gatling
H2 for rapid prototyping in local as well as support for R2DBC- Switched to a local postgres docker container to use more elaborate type, Range
- Use Database constraint to prevent double booking
- We can deal with the exception at the application level
- Since spring-data-r2dbc does not yet permit automatic creation of entity/table, we will use Flyway to handle that automatically