Skip to content

Latest commit

 

History

History
42 lines (32 loc) · 2.14 KB

File metadata and controls

42 lines (32 loc) · 2.14 KB

Koin Verticle Factory Example

This project shows how you can build a Verticle factory based Vert.x application using Koin, a A pragmatic lightweight dependency injection framework for Kotlin developers.

The project is Gradle based and it uses the Kotlin DSL to define all necessary Gradle files. It also uses the Vert.x Gradle Plugin for building and running the application.

The code is based on the Spring Verticle Factory example.

Trying

In a terminal, compile and run the example using:

---
./gradlew vertxRun
---

And in another tab or window, send a few requests to the server:

seq 10 | while read i; do curl http://localhost:8080/?name=Guido${i}; echo; done

If you look at the console, you’ll notice that the requests have indeed been managed by different event loops:

2019-01-07 13:09:05 [vert.x-eventloop-thread-2] INFO  i.vertx.koin.example.GreeterVerticle - Got request for name: Guido1
2019-01-07 13:09:05 [vert.x-eventloop-thread-4] INFO  i.vertx.koin.example.GreeterVerticle - Got request for name: Guido2
2019-01-07 13:09:05 [vert.x-eventloop-thread-3] INFO  i.vertx.koin.example.GreeterVerticle - Got request for name: Guido3
2019-01-07 13:09:06 [vert.x-eventloop-thread-1] INFO  i.vertx.koin.example.GreeterVerticle - Got request for name: Guido4
2019-01-07 13:09:06 [vert.x-eventloop-thread-2] INFO  i.vertx.koin.example.GreeterVerticle - Got request for name: Guido5
2019-01-07 13:09:06 [vert.x-eventloop-thread-4] INFO  i.vertx.koin.example.GreeterVerticle - Got request for name: Guido6
2019-01-07 13:09:06 [vert.x-eventloop-thread-3] INFO  i.vertx.koin.example.GreeterVerticle - Got request for name: Guido7
2019-01-07 13:09:06 [vert.x-eventloop-thread-1] INFO  i.vertx.koin.example.GreeterVerticle - Got request for name: Guido8
2019-01-07 13:09:06 [vert.x-eventloop-thread-2] INFO  i.vertx.koin.example.GreeterVerticle - Got request for name: Guido9
2019-01-07 13:09:06 [vert.x-eventloop-thread-4] INFO  i.vertx.koin.example.GreeterVerticle - Got request for name: Guido10