-
Notifications
You must be signed in to change notification settings - Fork 3
Description
As with #18, Feign supports non-blocking, reactive execution modes through wrappers andthrough Hystrix's Observable support. Given Feign's originated before non-blocking techniques such as reactive stream existed, attempting to add support to Feign has proven difficult. Non-blocking execution requires a mindset change due to it's use of an event loop and assumption that all events operate asynchronously.
We should take this opportunity to discuss how we can add non-blocking support, through the use of Reactive Streams or native java.util.concurrent.Flow available in JDK 9+.
Types to consider are:
- java.util.concurrent.Flow.Publisher
- org.reactivestreams.Publisher
Methods that specify these return types should be executed on an executor pool, either of the user's choosing or a reasonable default one, with their results returned directly, ideally after decoding the response. Care must be taken to ensure that any step in the request process that may block be wrapped and executed asynchronously to avoid blocking the event loop. The following list of components are capable of blocking:
- RequestEncoder
- RequestInterceptor
- Client
- ResponseDecoder
- ExceptionHandler
I suspect that the TargetMethodHandler implementation for these types will need to determine how to handle these cases.