Skip to content

Spring Isolation solves the confusion of multi-environment multi-branch service calls in the development environment or test environment. Spring Feign proxy solves the problems specified in the development of cross-group debugging services.

Notifications You must be signed in to change notification settings

hyuga0410/feign-isolation-component

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 

Repository files navigation

FeignIsolation

用于SpringBoot服务注册到nacos时通过追加服务名后缀进行服务隔离。

以及feignRequest调用时优先调用同属IP服务,不存在同属IP服务,再调用默认IP的服务。

所有使用该组件的服务均须提供redis配置。

注解类:FeignIsolation

  • environments(String[]:default dev):指定生效环境,默认dev
  • defaultIp:默认服务IP
  • isolationIps:需要强制隔离服务的IPS
  • skipIsolationServices:允许跳过隔离限制的服务(也可使用@FeignProvider指定去调用默认服务节点)
  • serviceSign:指定隔离的服务名标识 请求的service服务名中包含该标识才进行隔离
  • redisUrlPath:Redis地址配置路径
  • redisPortPath:Redis端口配置路径
  • redisUserPath:Redis用户配置路径
  • redisPwdPath:Redis密码配置路径

配置类

FeignIsolationConfiguration

@FeignIsolation注解相关配置信息读取,并注入系统变量feign-isolation-suffix值。

核心类

FeignIsolationCore

注入FeignBuilderHelperJedisTools,以及服务名心跳注册机制。

FeignBuilderHelper

FeignBuilderHelper实现feign请求动态调用。

DEMO

application.ymlbootstrap.yml添加${feign-isolation-suffix}

spring:
  application:
    name: service-hyuga-dict${feign-isolation-suffix}

启动类添加注解

@FeignIsolation(serviceSign = "-hyuga-", defaultIp = "127.0.0.1", isolationIps = "127.0.0.2#127.0.0.3", skipIsolationServices = "service-hyuga-dict")

FeignProxy

用于feignRequest执行时重定向请求地址

注解类

FeignProvider

  • value(String):调用服务的后缀名
  • environments(String[]:default dev):指定生效环境,默认dev

核心类

FeignBeanPostProcessor

在任何bean初始化回调之前,扫描含@Resource@FeignProvider的成员属性进行解刨处理,以实现feign请求动态调用。

DEMO

import javax.annotation.Resource;

@Resource
@FeignProvider(value = ".hyuga")
private HyugaDictFeign hyugaDictFeign;

About

Spring Isolation solves the confusion of multi-environment multi-branch service calls in the development environment or test environment. Spring Feign proxy solves the problems specified in the development of cross-group debugging services.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages