An open API service indexing awesome lists of open source software.

https://github.com/continuous1024/simple-rpc

最简单的RPC,使用接口进行RPC调用,使用Netty进行通信,使用JDK动态代理来实现客户端代理,使用CompletableFuture获取请求结果
https://github.com/continuous1024/simple-rpc

completable-future jdk-proxy netty-rpc rpc rpc-framework

Last synced: 3 months ago
JSON representation

最简单的RPC,使用接口进行RPC调用,使用Netty进行通信,使用JDK动态代理来实现客户端代理,使用CompletableFuture获取请求结果

Awesome Lists containing this project

README

          

# simple-rpc
算是最简单的RPC
- 使用接口进行RPC调用
- 使用Netty进行通信
- 使用JDK动态代理来实现客户端代理
- 使用CompletableFuture获取请求结果

## 示例
### 服务接口
```java
public interface DemoService {
String hello(String name);
}

```
### 暴露服务
```java
ServiceConfig serviceServiceConfig = ServiceConfig.builder()
.interfaceClass(DemoService.class)
.serviceImpl(new DemoServiceImpl()).build();
serviceServiceConfig.export();
```

### 服务调用
```java
ReferenceConfig referenceConfig = ReferenceConfig.builder()
.host("127.0.0.1").port(2880).interfaceClass(DemoService.class).build();
DemoService demoService = referenceConfig.refer();
String result = demoService.hello("World");
System.out.println(result);

System.out.println(demoService.hello("Huan Yu"));
```

## 借鉴Dubbo源码实现
阅读Dubbo源码之前或者之后,查看该源码会对rpc有一个很清晰的认识。