spring-cloud / spring-cloud-netflix

Integration with Netflix OSS components

Home Page:http://cloud.spring.io/spring-cloud-netflix/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sharing interface between client and controller with async return values

kflorence opened this issue · comments

Apologies if I should be asking this elsewhere, but is there any way to share an interface between a client and a controller when the controller has asynchronous return values? For example, if using Spring MVC and the controller has a method that returns a DeferredResult<FooResponse>, the client would need only FooResponse thus breaking the contract defined in the interface.

See also OpenFeign/feign#24 -- the fact that Feign does not support async might not matter as long as there is some way we can unwrap the async value in the client.

The client isn't asynchronous. I'm not sure this makes sense.

@spencergibb The client itself is not asynchronous, but I think it will be fairly common for the client to interact with a service that is (especially in Spring MVC) -- I think it's a pretty big downside to not be able to share the contract between the client and service just because the service uses asynchronous return values.

Our current workaround is to just put the client implementation of asynchronous service methods outside of our shared interface and changing the signature of the return value in the client.

@kflorence I don't think it's wise to share the interfaces. I opened #659 to discuss the possibility of deprecating and eventually removing the spring mvc annotation support, mostly to avoid the sharing.

@spencergibb perhaps the sharing of interfaces is not the best solution, but I do think it is really advantageous to be able to share the same signatures/routes between both as it reduces the chance of human error bugs. Definitely open to other solutions/suggestions to the problem.

I do think it is really advantageous to be able to share the same signatures/routes between both as it reduces the chance of human error bugs.

That's the rub, you can get close, bet never close enough, especially for something like async that the client knows nothing about.

Feign might eventually support async, FYI.

@kflorence I know, I watch the feign repo and the maintainer is my teammate. Even if it does support it, I would hesitate to support DeferredResult on the client side.