-
Notifications
You must be signed in to change notification settings - Fork 3
Description
One of the shortcomings of Feign is that support asynchronous execution modes is limited to those using Hystrix and their Observable support. Others have looked into supporting this, but have come the same conclusion, adding support for async modes requires a reconsideration of how Feign manages request execution.
Given that this project is "green-field", I would like to propose that we consider supporting, at a minimum, Future and CompletableFuture return types in the core library.
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. Here is an example:
public interface Blog {
@Request(value = "/posts", method = HttpMethod.GET)
CompletableFuture<Posts> getPosts();
}
public class BlogPostRepository {
private BlogService blog;
public Collection<Post> getPosts() {
CompleteableFuture<Collection<Post> posts = this.blog.getPosts()
.thenAccept(posts -> posts.stream().collect(Collectors.toList());
return posts.get();
}
}This, in my mind, would be an ideal place to start.