liubao68 commented on issue #2152:
URL:
https://github.com/apache/servicecomb-java-chassis/issues/2152#issuecomment-748985847
FallbackPolicy 的实现是 bean, 可以参考其他 java-chassis 的实现, 比如:
```
@Component
public class FromCacheFallbackPolicy implements FallbackPolicy {
private static final String POLICY_NAME = "fromCache";
private Map<String, Response> cachedResponse = new ConcurrentHashMap<>();
@Override
public String name() {
return POLICY_NAME;
}
@Override
public Response getFallbackResponse(Invocation invocation, Throwable
error) {
if (cachedResponse.get(invocation.getInvocationQualifiedName()) != null)
{
return cachedResponse.get(invocation.getInvocationQualifiedName());
} else {
return Response.succResp(null);
}
}
@Override
public void record(Invocation invocation, Response response, boolean
isSuccess) {
if (isSuccess) {
cachedResponse.put(invocation.getInvocationQualifiedName(), response);
}
}
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]