a rest client like feign+ribbon+eureka+spring

use spring eureka without spring-cloud

一个类似与feign+ribbon+eureka 代码也参考了以上开源项目的代码

可以访问普通的http 也可以访问eureka注册中心 支持负载均衡

https://github.com/yiwugou/homer

a rest client like feign


@RequestUrl({ "http://127.0.0.1:8762", "http://127.0.0.1:8763", "http://127.0.0.1:8764" })
@RequestConfig(execute = 10000, active = 10000)
public interface DemoService {

    @RequestMapping("foo")
    @RequestConfig(execute = 10000, active = 10000, loadBalance = LoadBalanceEnum.ROUND_ROBIN)
    String foo();

    @RequestMapping(value = "foo1/{username}/{password}", method = MethodEnum.GET)
    String foo1(@RequestParam("username") String username, @RequestParam("password") String password);

    @RequestMapping(value = "foo2", method = MethodEnum.GET)
    String foo2Get(@RequestParam("username") String username, @RequestParam("password") String password);

    @RequestMapping(value = "foo2", method = MethodEnum.POST)
    String foo2Post(@RequestParam("username") String username, @RequestParam("password") String password);
}

DemoService demoService = Homer.builder().proxy(DemoService.class);

use properties file

homer.properties


com.yiwugou.homer.core.test.DemoService.url=http://127.0.0.1:8762;http://127.0.0.1:8763;http://127.0.0.1:8764;
com.yiwugou.homer.core.test.DemoService.execute=100
com.yiwugou.homer.core.test.DemoService.foo.execute=10


DemoService demoService = Homer.builder().configLoader(new PropertiesFileConfigLoader("homer.properties")).proxy(DemoService.class);

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容