Skip to content

Support Future and other asynchronous execution modes #18

@kdavisk6

Description

@kdavisk6

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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions