Giter Site home page Giter Site logo

puck-ini / zrpc Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 309 KB

基于 Netty、Spring Boot 的简易 RPC 框架。 注册中心可以使用 Nacos 或者 Zookeeper,支持 protostuff、kryo、hessian2、fastjson序列化方式

Java 100.00%
spring-boot spring-boot-starter netty nacos kryo hessian2 fastjson cglib protostuff

zrpc's Introduction

简易RPC框架

zrpc-spring-boot-starter 模块

zrpc-spring-boot-starter 模块为 rpc 的主要实现,结构如下:

├─annotation 注解相关
├─cluster 负载均衡
├─config 配置相关、注册服务、注入服务
├─constants 常量
├─exception 异常
├─model 请求数据以及返回数据的格式定义
├─proxy 客户端发送请求代理
├─register 服务发现实现
├─remote 客户端和服务端实现
│  ├─client 客户端实现
│  ├─codec 解码编码器实现
│  ├─handler 请求处理器以及响应处理器
│  └─server 服务端实现
├─serializer 序列化方式
│  ├─fastjson
│  ├─hessian
│  ├─kryo
│  └─protostuff
└─util 工具类

zrpc-spring-boot-test 模块

zrpc-spring-boot-test 为测试模块,demo-consumer 和 demo-provider 启动 nacos 后可直接运行测试,也可以在application配置文件中修改配置更换注册中心。

例如:

zrpc:
  register-address: 127.0.0.1:2181 # 注册中心地址
  register-protocol: zookeeper # 注册中心,有 nacos 和 zookeeper 两种
  proxy: jdk # 代理方式,有 jdk 和 cglib 两种实现

启动后访问 http://localhost:9090/v1/get 即可看到结果。

使用方式

定义接口:

public interface DemoService {

    String getMsg();

}

接口实现,在实现类加入 @ZService 注解:

@ZService
public class DemoServiceImpl implements DemoService {

    @Override
    public String getMsg() {
        return "getMsg: " + System.currentTimeMillis();
    }

}

调用接口,使用 @ZReference 调用接口:

    @ZReference
    private DemoService demoService;

zrpc's People

Contributors

puck-ini avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

zrpc's Issues

Gou Zhou New Bee!!!!

You have been new bee to write RPC framework. I am so vegetable that I can't follow Gou Zhou's stpes. Please wait for me and stop studying!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.