반응형
SMALL
Kotlin
-
Kotlin Arrow CircuitBreakerKotlin/Arrow 2025. 8. 2. 19:50
서킷브레이커의 메소드는 protectEither와 protectOrThrow가 있습니다.protectEither 는 내부에서 protectOrThrow를 호출하고 있고, catch로 exception을 잡은 다음 Left로 리턴하고 있습니다.서킷브레이커의 초기 상태는 Closed 이기 때문에 when 절의 Closed를 보면호출했던 람다 파라미터를 실행하고 right() 를 호출하여 Either로 감싸고 있습니다.람다로 감싸진 결과 값은 markOrResetFailures 메소드의 파라미터로 들어가게 되고해당 메소드는 Closed 상태에서 Right 인지 Left 인지 확인 후 이후 로직을 실행합니다.여기서 protectOrThrow 또는 protectEither 에 넣는 람다 메소드가 Either를 리..