Giter VIP home page Giter VIP logo

myrpc's Introduction

根据netty实现RPC框架

服务注册中心

服务启动 Bootstrap

  1. 扫描指定路径中的需要注册的服务及其暴露的方法,缓存在本地
  2. 获取服务的实现类,初始化并注册(放入本地内存中)
  3. 监听端口

服务处理

  1. 解析请求体,获取模块号和操作号和有关参数信息
  2. 通过注册好的对象,反射执行方法,获取执行结果
  3. 序列化结果并返回响应

客户调用端

调用端启动

和服务端一样,进行扫描,缓存信息

调用指定服务

  1. 生成代理
  2. 如果服务为本地实现类直接调用本地方法,否则进行rpc调用
  3. 将调用的服务和方法封装为符合指定协议的请求体,发送请求到指定ip和端口
  4. 将响应反序列化,得到调用结果
  5. 返回代理的执行结果

channel传递数据

自定义序列化协议

用于RPC中传输数据,一般将数据转换为二进制格式,节省开销。 该项目采用自定义的序列化协议,以Netty的ByteBuf为基础进行序列化:https://github.com/AzeroCoder/MySerializer

自定义网络协议

  • 包号:即分隔符,用于分包,避免粘包现象
  • 模块号:访问的资源,映射为类
  • 操作号:访问的方式,映射为方法
  • 具体数据的大小和内容(需要序列化)

Snipaste_2021-03-04_10-50-20 image

myrpc's People

Contributors

corncarrots avatar

Stargazers

Zekang Qiu avatar  avatar jlzhang avatar clown avatar

Watchers

 avatar

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.