Eureka Server 代码分析01

Eureka Server 配置

InstanceStatus: 实例状态
    public enum InstanceStatus {
        UP, // Ready to receive traffic 准备接收通信(流量)
        DOWN, // Do not send traffic- healthcheck callback failed 不发送流量,服务健康检查调用失败
        STARTING, // Just about starting- initializations to be done - do not
        // send traffic
        OUT_OF_SERVICE, // Intentionally shutdown for traffic 故意关闭流量
        UNKNOWN;

        public static InstanceStatus toEnum(String s) {
            if (s != null) {
                try {
                    return InstanceStatus.valueOf(s.toUpperCase());
                } catch (IllegalArgumentException e) {
                    // ignore and fall through to unknown
                    logger.debug("illegal argument supplied to InstanceStatus.valueOf: {}, defaulting to {}", s, UNKNOWN);
                }
            }
            return UNKNOWN;
        }
    }

Spring Boot 的核心机制SPI (Service Provider Interface),SPI 是一种为某个接口寻找服务实现的机制。

Spring Boot 的SPI机制:

      在Spring Boot 自动装配中,SpringFactoriesLoader会加载META-INF/spring.factories文件,

  会扫描所有路径下jar包中搜索所有META-INF/spring.factories配置文件,然后解析properties,找到指定名称的配置后返回。

posted @ 2019-06-23 18:58  华样年花  阅读(133)  评论(0编辑  收藏  举报