package com.usky.alarm.factory;

import com.usky.alarm.RemoteWebSocketService;
import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.exception.BusinessException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;


/**
 * 用户服务降级处理
 *
 * @author ruoyi
 */
@Component
public class RemoteWebSocketFallbackFactory implements FallbackFactory<RemoteWebSocketService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteWebSocketFallbackFactory.class);

    @Override
    public RemoteWebSocketService create(Throwable throwable)
    {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteWebSocketService() {
            @Override
            public ApiResult<Void> selfCheck(String requestBody) {
                throw new BusinessException(throwable.getMessage());
            }
        };
    }
}
