Skip to content

spring cloud openfeign 自定义负载均衡(loadbalance)插件,可细化到接口

License

Notifications You must be signed in to change notification settings

patinousward/spring-cloud-openfeign-lb-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spring-cloud-openfeign-lb-plugin

1.QuickStart

  • 1.1 自定义负载均衡规则

自定义类继承AbstractLBRule,rule方法中填充自己的负载均衡算法即可,可参考HashLBRule这个实现类

  • 1.2 在feign接口中显示调用url,其值为负载均衡规则的name,example:
@FeignClient(value= "xxx",url = HashLBRule.NAME)
public interface MyFeign{
}
  • 1.3 创建bean即可,example:
@Configuration
public class CustomizeBeanConfiguration{
    
    @Bean
    public LBRule getLBRule(){
        return new HashLBRule(MyFeign.class,"key")
    }

    @Bean
    public LBRule getLBRule2(){
        return new HashLBRule2(MyFeign2.class,"key")
    }

    xxx

}

About

spring cloud openfeign 自定义负载均衡(loadbalance)插件,可细化到接口

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages