Created
May 21, 2021 11:52
-
-
Save Jian-Min-Huang/91728f571655fd6448adf1a7be949412 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun flux() = | |
| Flux.mergeSequential(getMonoResponse(100), getMonoResponse(200)) | |
| .collectList() | |
| .flatMap { v -> | |
| return@flatMap getMonoResponse(300) | |
| .map { v2 -> | |
| v.add(v2) | |
| return@map v | |
| } | |
| }.flatMap { v -> | |
| val period = v[2]["totalTimeMillis"].parseLong() | |
| Flux.mergeSequential(getMonoResponse(period + 100), getMonoResponse(period + 200)) | |
| .collectList() | |
| .map { v2 -> | |
| v.addAll(v2) | |
| return@map v | |
| } | |
| }.map { v -> | |
| mapOf( | |
| "delay100res" to v[0]["totalTimeMillis"], | |
| "delay200res" to v[1]["totalTimeMillis"], | |
| "delay300res" to v[2]["totalTimeMillis"], | |
| "delay400res" to v[3]["totalTimeMillis"], | |
| "delay500res" to v[4]["totalTimeMillis"] | |
| ) | |
| } | |
| private fun getMonoResponse(ms: Long) = webClient.get() | |
| .uri("http://$domain:8888/delay/ms/$ms") | |
| .retrieve() | |
| .bodyToMono(object : ParameterizedTypeReference<Map<*, *>>() {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment