/webflux-demo

microservice demo with webflux

Primary LanguageKotlin

webflux-demo

Keywords

  • webflux, kotlin, coroutine, functional, swagger, elasticsearch

Environments

  • mac
  • intelliJ
  • docker
  • jq

Get Started

# exec elasticsearch, kibana
$ es/docker-compose up

# insert init data
$ sh es/migrate.sh

Features

  • Without Spring Data Elasticserach or ELastic Rest High Level Client
    • Using WebClient and raw Query
fun searchRecipes(keywords: String, size: Int): Flow<Any> = webClient
      .post()
      .uri("/omtm/recipe/_search")
      .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
      .bodyValue("""
          {
            "query": {
              "multi_match": {
                "query": "$keywords",
                "fields": ["description","title^0.5"]
              }
            },
            "size": $size
          }
      """.trimIndent())
      .retrieve()
      .bodyToFlux(Any::class.java)
      .asFlow()

Futhermore

  • apply validator to check request params
  • ecs task definition for auto deploy
  • optimize coroutine for async
  • optimize ES architecture, query