You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/12/21 13:55:50 UTC

[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2152: 写了一个记录三方请求的logFilter,当请求三方接口超时,logFilter无法接收到response,导致三方日志不打印

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:
users@infra.apache.org