-
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
Adds fallback implementation configuration to the HystrixFeign builder #308
Conversation
78c00d1
to
fa7548c
Compare
NetflixOSS » feign » feign-pull-requests #195 SUCCESS |
ps @spencergibb at the level of abstraction of feign, it doesn't care how the fallback instance is created. so, it could be created by a dynamic proxy or whatever (which I suspect would be the way to integrate with custom annotation processing) |
HystrixFeign
builder
will merge this in 8hrs unless there's blocking feedback, as there are folks waiting on 8.14 |
fa7548c
to
9e4025d
Compare
scrubbed covariants after seeing this! https://gist.github.com/JakeWharton/14547311b1f145cb0695 |
9e4025d
to
41756c3
Compare
Fallbacks are known values, which you return when there's an error invoking an http method. For example, you can return a cached result as opposed to raising an error to the caller. To use this feature, pass a safe implementation of your target interface as the last parameter to `HystrixFeign.Builder.target`. Here's an example: ```java // When dealing with fallbacks, it is less tedious to keep interfaces small. interface GitHub { @RequestLine("GET /repos/{owner}/{repo}/contributors") List<String> contributors(@param("owner") String owner, @param("repo") String repo); } // This instance will be invoked if there are errors of any kind. GitHub fallback = (owner, repo) -> { if (owner.equals("Netflix") && repo.equals("feign")) { return Arrays.asList("stuarthendren"); // inspired this approach! } else { return Collections.emptyList(); } }; GitHub github = HystrixFeign.builder() ... .target(GitHub.class, "https://api.github.com", fallback); ``` Credit to the idea goes to @stuarthendren!
41756c3
to
122f9a5
Compare
NetflixOSS » feign » feign-pull-requests #198 SUCCESS |
Adds fallback implementation configuration to the HystrixFeign builder
this is now released as 8.14 cc @christopherlakey |
Adds fallback implementation configuration to the HystrixFeign builder
Fallbacks are known values, which you return when there's an error invoking an http method.
For example, you can return a cached result as opposed to raising an error to the caller. To use
this feature, pass a safe implementation of your target interface as the last parameter to
HystrixFeign.Builder.target
.Here's an example:
Credit to the idea goes to @stuarthendren!
Fixes #298