-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Per request timeout options #562
Comments
There's no way to do this in the same interface. You'd have to create
multiple instances of feign, one for each deviation to Request.Options.
|
well. that or make a Client wrapper which constructs options based on
the endpoint or something..
|
@adriancole
|
We really need it. |
Thanks for taking the time and looking into this for us. My thoughts on this are that instead of creating a dedicated annotation, that we add these as optional values on the |
@kdavisk6 |
@kdavisk6, @tatyanayavkina I guess it is not the scope of this project, but a dedicated Annotation would make it easier for https://github.com/spring-cloud/spring-cloud-openfeign Users |
Maybe have to take back my previous comment: But not sure how upstream compatibility is handled in this project. org.springframework.cloud.openfeign.support.SpringMvcContract is using "@RequestMapping", which is the same Annotation for Controller (request-handling classes) mappings. |
I've reimplemented "per request timeout" via As @rowi1de has noted, spring-cloud-openfeign will not get "per request timeout" feature out of the box anyway. Contracts that defined in open-feign use delegate contracts (except of JAXRSContract). And these contracts will support "per request timeout" only if delegate contract supports it. In my opinion, both implementations require the same code change size. But I think that @ApiTimeout implementation is better, because timeout settings and What do you think? |
Or, we can use public Map<String, MethodHandler> apply(Target key) {
List<MethodMetadata> metadata = contract.parseAndValidatateMetadata(key.type());
Map<SomeMethodName,RequestOption> timeoutOptions = ApiTimeoutParser.parseOptions(key.type());
Map<String, MethodHandler> result = new LinkedHashMap<String, MethodHandler>();
for (MethodMetadata md : metadata) {
...
Options requestOptions = [if (optionsPerMethod contains timeoutOptions for method) then use timeoutOptions else use options];
result.put(md.configKey(),
factory.create(key, md, buildTemplate, requestOptions, decoder, errorDecoder));
}
return result;
} and no need to make changes in all Contracts to support timeout options. |
There is not much we can do about custom Another possible solution is to update interface MyClient {
@RequestLine("GET /data")
public MyResponse getMyData(Request.Options options);
} This could then be used by any other derivative contract, here is an example of how this could work with Spring Cloud interface MyClient {
@RequestMapping(path = "/data")
public MyResponse getMyData(Request.Options options);
} What do you think? |
I think I have not enough expertise to implement this feature correctly, so I closed my pr. |
No need to close the PR. I am only one voice here and after talking about it with a few others, your approach does work and meets the needs of those interested in this feature. If you are still interested in working on this, please feel free to re-open or submit a new PR for review. |
* Aadd Options Test * Ignore Options when set bodyIndex
* Add Options UT * Ignore Options when set bodyIndex
* Add Options UT * Ignore Options when set bodyIndex
…enFeign#970) * Add Options UT * Ignore Options when set bodyIndex
We have an API that we are using that expects us to use long polling for a GET request. We can change the timeouts to support that, but there are other calls in the API that don't support long polling and we want the timeouts to be smaller for those calls. Is there a way to support this with Feign?
The text was updated successfully, but these errors were encountered: