package com.sptg.permissions.api.feigns.fallback;

import com.sptg.common.core.constant.CommonConstant;
import com.sptg.permissions.api.entity.Conf;
import com.sptg.permissions.api.feigns.ConfFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * title: ConfFeignFallbackFactority
 * package: com.sptg.permissions.api.feigns.fallback
 * description:
 *
 *                  
 *                
 */
@Component
@Slf4j
public class ConfFeignFallbackFactory implements FallbackFactory<ConfFeign> {

    @Override
    public ConfFeign create(Throwable cause) {
        return new ConfFeign() {
            @Override
            public String getFileServerHost() {
                log.error(cause.getMessage(),cause);
                return CommonConstant.EMPTY;
            }

            @Override
            public Conf getEntityByToken(String token) {
                log.error(cause.getMessage(),cause);
                return null;
            }
        };
    }
}
