Closed
Description
I tried to marry Retrofit and Hystrix together but that appears to be quite a cumbersome process. Ideally, I'd like to have something like this
@POST("...")
@HystrixCommand(groupKey="...", commandKey="...")
Observable<SomeObject> get();
However Retrofit uses JDK proxies and annotation info is not preserved so AOP stuff that wires together annotations and actual code does not work. For now, I had to create classes that match methods on interfaces and put @HystrixCommand
into class methods instead. That does not look nice as I have to double the code.
Maybe allowing pluggable proxy (cglib, byte-buddy, etc) solution would be helpful in the long term here.
Activity
liangGTY commentedon Nov 23, 2017
hystrix-adapters? I think this is very good
swankjesse commentedon Feb 26, 2018
It’s not necessarily going to be a good fit because of the way Retrofit returns asynchronous objects. I think Hystrix is going to want to time the network call, not the method call to create an observable, etc.
Probably better to integrate Hystrix as a custom CallAdapter.
swankjesse commentedon Feb 26, 2018
(closing because I don’t think we’re going to get to this. If somebody would like to write a call adapter that hooks up Hystrix, that’d be great!)
liangGTY commentedon Feb 26, 2018
I've written a simple hystrix callAdapter before。But not supported fallback
hystrix callAdapter