Skip to content

luizinhoab/planet-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Planet API

Build Status 78f9b8b12c154d27b7e5c9c3ceff438e Codacy code quality

vert.x 3.6.3 purple

The purpose of this application was the challenge participation proposed by B2W hiring team.This api was specified and documented under Open API 3 standard and can be consulted on https://app.swaggerhub.com/apis-docs/luizinhoab/b2w-challenge/1.0.0 .

This application exposes a reactive rest microservice, under Java/Vert.x, with crud operations to handle planets persited on MongoDb.

Running

Will need install OpenJDK 11 and Gradle 5.2 to build and run the app. Optionally install Docker to run the container with MongoDb and sample data loaded, is same image used in the integration tests.

Development :

Sample Database
docker build -t mongo-test . && docker run -p 0.0.0.0:27016:27016 --name mongo-dev -d  -t  -i  mongo-test
Intelij
Main Class: io.vertx.core.Launcher
VM Options:
  -Dvertx.metrics.options.enabled=true
  -Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.Log4j2LogDelegateFactory
  --add-exports
  java.base/jdk.internal.misc=ALL-UNNAMED
  -Dio.netty.tryReflectionSetAccessible=true
Program arguments: run io.starwars.planet.PlanetAPIVerticle -conf src/main/resources/conf/config-dev.json
Gradle
./gradlew clean run

Test :

Unit

./gradlew clean test

Integration

./gradlew clean integrationTest

Check

Run complete verification, currently unit and integration tests, runned by Travis.

./gradlew clean check

Production :

Packaging
./gradlew clean shadowJar
Start application
java -Dvertx.metrics.options.enabled=true
     -Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.Log4j2LogDelegateFactory
     --add-exports java.base/jdk.internal.misc=ALL-UNNAMED
     -Dio.netty.tryReflectionSetAccessible=true
     -jar plane-api-<VERSION>.jar -conf src/main/resources/conf/config-dev.json

Health & Metrics

The project exposes two health resources with associated metrics, for this is needed, before run app, to set the Vm Option:

'-Dvertx.metrics.options.enabled=true`.

Exposed resources:

/health - with all metrics about Vertx instance running.
/health/server - just with metrics about the api server.

Built with

  • OpenJDK 11 - Java 11

  • Vert.x - Eclipse Vert.x is a tool-kit for building reactive applications on the JVM.

  • Open API 3 - Design API

  • Gradle Dependency management and tasks automatization