package com.ard.system.api.factory; import com.ard.common.core.domain.R; import com.ard.system.api.RemoteConfigService; import com.ard.system.api.domain.SysConfig; 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 RemoteConfigFallbackFactory implements FallbackFactory { private static final Logger log = LoggerFactory.getLogger(RemoteConfigFallbackFactory.class); @Override public RemoteConfigService create(Throwable throwable) { log.error("系统总配置:{}", throwable.getMessage()); return new RemoteConfigService() { @Override public R> listRpc(SysConfig sysConfig, String source) { return R.fail("查询报警总配置列表:" + throwable.getMessage()); } @Override public R getConfigKey(String configKey) { return R.fail("查询配置失败:" + throwable.getMessage()); } }; } }