simple-rpc基于 netty 的 RPC 框架
simple-rpc 是一款基于 netty 的 RPC 框架,現(xiàn)有功能:
基本的客戶端、服務(wù)端交互
提供代理實(shí)現(xiàn)接口
spring 集成, xml配置和Java Config配置方式
服務(wù)發(fā)布訂閱 DONE
斷線重連 DONE
RoadMap
服務(wù)心跳檢測(cè)
連接池
服務(wù)注冊(cè)發(fā)布功能
服務(wù)管理、監(jiān)控
服務(wù)調(diào)用日志鏈路跟蹤
集成swagger功能,提供文檔、測(cè)試、客戶端生成
使用示例
// 服務(wù)接口
public interface IHello {
`
String say(String hello);
int sum(int a, int b);
int sum(Integer a, Integer b);
}
// 服務(wù)實(shí)現(xiàn)
public class HelloImpl implements IHello {
public String say(String hello) {
return "return " + hello;
}
public int sum(int a, int b) {
return a + b;
}
public int sum(Integer a, Integer b) {
return a + b * 3;
}
}
// 客戶端代碼
// beanJavaConfig方式
@Bean
public CountService countService() {
RpcClientWithLB rpcClientWithLB = new RpcClientWithLB("fyes-counter");
rpcClientWithLB.setZkConn("10.4.105.252:2181");
rpcClientWithLB.init();
CountService countService = rpcClientWithLB.newProxy(CountService.class);
return countService;
}
// 服務(wù)端發(fā)布
// xml配置方式
<bean class="com.github.liuzhengyang.simplerpc.ServerFactoryBean" init-method="start">
<property name="serviceInterface" value="com.test.liuzhengyang.CountService"/>
<property name="port" value="8888"/>
<property name="serviceName" value="fyes-counter"/>
<property name="serviceImpl" ref="countServiceImpl"/>
<property name="zkConn" value="127.0.0.1:2181"/>評(píng)論
圖片
表情
