项目作者: rainmanhhh

项目描述 :
make it easy to use kotlin coroutines in quarkus project
高级语言: Kotlin
项目地址: git://github.com/rainmanhhh/ez-quarkus-vertx-kotlin.git
创建时间: 2020-04-16T10:24:17Z
项目社区:https://github.com/rainmanhhh/ez-quarkus-vertx-kotlin

开源协议:MIT License

下载


ez-quarkus-vertx-kotlin

make it easy to use kotlin coroutines in quarkus project

usage

  • create a project with quarkus starter(https://code.quarkus.io/).

    recommanded extension(s):

    • RESTEasy JSON-B(or RESTEasy Jackson, but you need to config jdk8 LocalDate/LocalTime/LocalDateTime serializer manually)
    • SmallRye OpenAPI
    • SmallRye Health
    • SmallRye Metrics

    optional extension(s):

  • add jitpack to your repos
    1. <repository>
    2. <id>2-jitpack</id>
    3. <url>https://jitpack.io</url>
    4. </repository>
  • add dep
    1. <dependency>
    2. <groupId>com.github.rainmanhhh</groupId>
    3. <artifactId>ez-quarkus-vertx-kotlin</artifactId>
    4. <version>1.0</version>
    5. </dependency>
  • make your resource extends VertxScope and write async web endpoints with kotlin coroutines
    1. @Produces(MediaType.APPLICATION_JSON)
    2. @Path("/")
    3. class ExampleResource : VertxScope() {
    4. @GET
    5. @Path("hello")
    6. @Produces(MediaType.TEXT_PLAIN)
    7. fun helloAsync() = async {
    8. delay(1000)
    9. "hello"
    10. }
    11. @GET
    12. @Path("now")
    13. fun now() = LocalDate.now()
    14. }
  • config the app by application.yml(or application.properties)
    1. quarkus:
    2. index-dependency:
    3. kotlinx-coroutines:
    4. group-id: org.jetbrains.kotlinx
    5. artifact-id: kotlinx-coroutines-core
    6. eureka: # if you don't use eureka, skip this part
    7. region: default
    8. health-check-url: ${quarkus.smallrye-health.root-path:/health}
    9. status-page-url: ${quarkus.swagger-ui.path:/swagger-ui}
    10. service-url:
    11. defaultZone: http://127.0.0.1:8761/eureka/
    12. swagger-ui:
    13. always-include: true
    14. log:
    15. category:
    16. "io.quarkus.eureka.operation.heartbeat.HeartBeatOperation": # if you don't use eureka, skip this part
    17. level: WARNING
    18. "%dev":
    19. quarkus:
    20. vertx: # use small pools and disable thread-blocking check for profile dev
    21. event-loops-pool-size: 1
    22. worker-pool-size: 1
    23. warning-exception-time: 1h
    24. max-event-loop-execute-time: 1h
    25. max-worker-execute-time: 1h