It makes use of Vert.x reactive stream to read and write streams of data to the file. The good news is Vert.x has provided a read parser which can translate into a neat event stream. It also provides AsyncFile, a nice write stream on top of Vert.x file system.
With these in mind, it provides an ability to read from a TCP socket and write it into a file system. You can take the advantage of all back pressure startegies that already implemented. In addition to reading and writing, you can add validator, message convertor and they can participate in the same event streaming pipe.
One draw back you will see in this code repo is error handling. Errors are thrown at random places. Ideally we should have error handler and we should hook you that error handler in places where it is necessary. This allows one to have a singular error handling strategy. During this exercise I encountered couple of open defects in Vert.x
- JDK 11
- Maven 3.6.x
- bin # Executables used when building docker image
- checkstyle # Checkstly code linting rules
- src/main # All the source code
- src/tests # All unit tests
- src/it # All integration tests
- Dockerfile # Used to build docker image
- pom.xml # Maven pom file
- README.md # Info about the project
- start-local.sh # Shell script to start the server locally
The below command will run unit tests and integration tests. Checkstyle rules are applied to both source and test cases.
mvn clean install
If you are in a hurry and want to skip all tests -
mvn clean install -DskipTests
If you want to skip only the integration tests -
mvn clean install -DskipITs
if you are using Intellij, go any integration test file, scroll to intended test method. Right click on that test method, to run or debug.
Assuming you are in the root folder of the project, simply run the below command. On success, both the application log (simple-tcp-server.log) and "numbers.log" to the same directory.
If you want to alter the location of "numbers.log", change the value of the variable "NUMBERS_LOG_FILE" in "start-locally.sh" file.
./start-locally.sh
As given below, the commands will build the image and only then you can run.
Note: Since the container writes into numbers.log, the below command is asking you to mount a directory which the log files can be written. It also forwards port 4000 to the host.
On success, both the application log (simple-tcp-server.log) and "numbers.log" will be written to the mounted directory.
docker build -t example:1.0 .
docker run -p 4000:4000 -v <my-directoryt-to-be-mounted>:/var/log/example example:1.0
1. Via intellij IDE, go to plugins -> spring-boot->spring-boot:run
2. Via command client, run command "mvn install spring-boot:run"
The service uses Jacoco to track coverage. A consolidated reported is generated and its ready for access.
1. The unit test report is available at "<my-project>/target/site/jacoco/jacoco-ut/index.html"
2. The integration test report is available at "<my-project>/target/site/jacoco/jacoco-it/index.html"