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);
网友评论