-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added @FeignClient(fallback). Renamed FeignClientFactory to FeignContext. fixes gh-762
- Loading branch information
1 parent
390f001
commit f00f761
Showing
14 changed files
with
392 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...x-core/src/main/java/org/springframework/cloud/netflix/feign/support/FallbackCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,55 @@ | |||
package org.springframework.cloud.netflix.feign.support; | |||
|
|||
import com.netflix.hystrix.HystrixCommand; | |||
import com.netflix.hystrix.HystrixCommandGroupKey; | |||
import com.netflix.hystrix.HystrixThreadPoolKey; | |||
|
|||
/** | |||
* Convenience class for implementing feign fallbacks that return {@link HystrixCommand}. | |||
* Also useful for return types of {@link rx.Observable} and {@link java.util.concurrent.Future}. | |||
* For those return types, just call {@link FallbackCommand#observe()} or {@link FallbackCommand#queue()} respectively. | |||
* @author Spencer Gibb | |||
*/ | |||
public class FallbackCommand<T> extends HystrixCommand<T> { | |||
|
|||
private T result; | |||
|
|||
public FallbackCommand(T result) { | |||
this(result, "fallback"); | |||
} | |||
|
|||
protected FallbackCommand(T result, String groupname) { | |||
super(HystrixCommandGroupKey.Factory.asKey(groupname)); | |||
this.result = result; | |||
} | |||
|
|||
public FallbackCommand(T result, HystrixCommandGroupKey group) { | |||
super(group); | |||
this.result = result; | |||
} | |||
|
|||
public FallbackCommand(T result, HystrixCommandGroupKey group, int executionIsolationThreadTimeoutInMilliseconds) { | |||
super(group, executionIsolationThreadTimeoutInMilliseconds); | |||
this.result = result; | |||
} | |||
|
|||
public FallbackCommand(T result, HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool) { | |||
super(group, threadPool); | |||
this.result = result; | |||
} | |||
|
|||
public FallbackCommand(T result, HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool, int executionIsolationThreadTimeoutInMilliseconds) { | |||
super(group, threadPool, executionIsolationThreadTimeoutInMilliseconds); | |||
this.result = result; | |||
} | |||
|
|||
public FallbackCommand(T result, Setter setter) { | |||
super(setter); | |||
this.result = result; | |||
} | |||
|
|||
@Override | |||
protected T run() throws Exception { | |||
return this.result; | |||
} | |||
} |
Oops, something went wrong.
raised this to fix it upstream. missing tests (are my fault)! OpenFeign/feign#317