package com.ard.work.api.factory;
|
|
import com.ard.common.core.domain.R;
|
import com.ard.work.api.RemoteHealthService;
|
import com.ard.work.api.domian.AlertInfoDto;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
import org.springframework.stereotype.Component;
|
|
import java.util.List;
|
|
/**
|
* 设备健康服务降级处理
|
*
|
* @author ard
|
*/
|
@Component
|
public class RemoteHealthFallbackFactory implements FallbackFactory<RemoteHealthService>
|
{
|
private static final Logger log = LoggerFactory.getLogger(RemoteHealthFallbackFactory.class);
|
|
@Override
|
public RemoteHealthService create(Throwable throwable)
|
{
|
log.error("设备健康服务调用失败:{}", throwable.getMessage());
|
return new RemoteHealthService()
|
{
|
@Override
|
public R<List<AlertInfoDto>> getAlertInfo(String source) {
|
return R.fail("获取设备健康报警信息失败:" + throwable.getMessage());
|
}
|
};
|
}
|
}
|