Reactor with kotlin
Table of Contents
Mono
-
Mono.fromCallable: https://kwonnam.pe.kr/wiki/reactive_programming/reactor -
flatMapMany(): Mono를 Flux로 리턴
Examples
println("start")
val list: List<Mono<Int>> = listOf(
Mono.just(1),
Mono.just(2),
Mono.just(3),
Mono.just(4),
Mono.just(5),
Mono.just(6)
)
list.forEach { el ->
Thread.sleep(500)
println(el.block())
}
println("end")
result
start
1
2
3
4
5
6
end
|
Mono.error
Mono.error가 반횐되었을 떄
|
Error Handling
subscribe vs. subscribeOn
-
subscribe는 현재 스레드에서 시작됨. -
subscribeOn은 실행할 스레드를 지정함.
|
Lettuce의
ReactiveRedisTemplate 사용시 비동기 처리Redis를 Lettuce 라이브러리 사용하여 |
Etc
-
마블 다이어그램: https://brunch.co.kr/@lonnie/20