All Projects → cocolian → cocolian-rpc

cocolian / cocolian-rpc

Licence: other
使用Apache Thrift作为容器,Google Protobuf作为协议的一个RPC框架。

Programming Languages

java
68154 projects - #9 most used programming language
Thrift
134 projects

Projects that are alternatives of or similar to cocolian-rpc

Grpc
An Elixir implementation of gRPC
Stars: ✭ 858 (+4415.79%)
Mutual labels:  protobuf, rpc
Twisk
Golang RPC starter kit with Twirp
Stars: ✭ 113 (+494.74%)
Mutual labels:  protobuf, rpc
Easyrpc
EasyRpc is a simple, high-performance, easy-to-use RPC framework based on Netty, ZooKeeper and ProtoStuff.
Stars: ✭ 79 (+315.79%)
Mutual labels:  protobuf, rpc
Getty
a netty like asynchronous network I/O library based on tcp/udp/websocket; a bidirectional RPC framework based on JSON/Protobuf; a microservice framework based on zookeeper/etcd
Stars: ✭ 532 (+2700%)
Mutual labels:  protobuf, rpc
Netty Learning Example
🥚 Netty实践学习案例,见微知著!带着你的心,跟着教程。我相信你行欧。
Stars: ✭ 2,146 (+11194.74%)
Mutual labels:  protobuf, rpc
Brpc Java
Java implementation for Baidu RPC, multi-protocol & high performance RPC.
Stars: ✭ 647 (+3305.26%)
Mutual labels:  protobuf, rpc
Twirp
PHP port of Twitch's Twirp RPC framework
Stars: ✭ 108 (+468.42%)
Mutual labels:  protobuf, rpc
Flatbuffers
FlatBuffers: Memory Efficient Serialization Library
Stars: ✭ 17,180 (+90321.05%)
Mutual labels:  protobuf, rpc
Go Micro Boilerplate
The boilerplate of the GoLang application with a clear microservices architecture.
Stars: ✭ 147 (+673.68%)
Mutual labels:  protobuf, rpc
Raptor
拍拍贷微服务rpc框架
Stars: ✭ 139 (+631.58%)
Mutual labels:  protobuf, rpc
Srpc
RPC based on C++ Workflow
Stars: ✭ 521 (+2642.11%)
Mutual labels:  protobuf, rpc
Go Grpc Examples
This repo contains examples and implementations of different types of GRPC services and APIs using Golang.
Stars: ✭ 180 (+847.37%)
Mutual labels:  protobuf, rpc
Twirp
A simple RPC framework with protobuf service definitions
Stars: ✭ 5,380 (+28215.79%)
Mutual labels:  protobuf, rpc
Rpc Thunderdome
A comparison between Proteus RPC and other commonly used RPC frameworks
Stars: ✭ 22 (+15.79%)
Mutual labels:  protobuf, rpc
Cellnet
High performance, simple, extensible golang open source network library
Stars: ✭ 3,714 (+19447.37%)
Mutual labels:  protobuf, rpc
Protobuf
Protocol Buffers - Google's data interchange format
Stars: ✭ 52,305 (+275189.47%)
Mutual labels:  protobuf, rpc
rony
Fast and Scalable RPC Framework
Stars: ✭ 41 (+115.79%)
Mutual labels:  protobuf, rpc
Yarpc Go
A message passing platform for Go
Stars: ✭ 285 (+1400%)
Mutual labels:  protobuf, rpc
Mrpc
🐿 netty,zookeeper,spring,kyro rpc framework.
Stars: ✭ 128 (+573.68%)
Mutual labels:  protobuf, rpc
Gayrpc
Full Duplex C++ RPC Library,Use Protobuf, Support HTTP API .
Stars: ✭ 157 (+726.32%)
Mutual labels:  protobuf, rpc

一、功能

cocolian-rpc是一个RPC容器和客户端连接池的实现。

  • cocolian-rpc-server: 使用Apache Thrift 作为容器,Protobuf Message作为输入输出参数的RPC服务器;
  • cocolian-rpc-client: 客户端的实现,提供一个连接池。
  • cocolian-rpc-service: 服务器端和客户端共用的一些服务,比如zookeeper注册参数对象、一些共用的thrift对象等。
  • cocolian-rpc-docker:运行rpc服务器的docker 镜像。

二、cocolian-rpc-server

使用Apache Thrift 作为RPC Server, Protobuf Message作为输入输出参数。 Apache Thrift作为Server,我们以这个Servce作为基础服务:

service BaseService {
  /**
    * 通用的execute服务。
   **/
    binary execute(1:binary request)
    throws(   1:NotFoundException notFoundException,
              2:SystemException systemException,
              3:UserException userException
    );
  
}

在上述定义中, 当客户端向服务器端请求BaseService::execute操作时,Thrift 有如下处理:

  • BaseService不会被编码到调用中, 也就是服务名称是FooService, BarService, 对这个调用是没有影响的。
  • execute是在Thrift 编码的头中定义的,所以只要把这个头读出来,就知道调用的是什么方法 。
  • Protobuf Message 可以很容易的转换成binary字节,通过Thrift来传输到服务器端。 处理完成后, 将结果也是表示成ProtobufMessage,传输到客户端。

而Protobuf Message提供如下比Thrift 的struct更有优势的特性:

  1. 压缩率高, 性能更好。
  2. 可扩展性更好。 只要保持序号和类型的一致性,可添加optional的参数。 特别是对enum类型的兼容性支持。
  3. option提供类似java annotation的支持。

基于上述考虑,我们使用Apache Thrift + Protobuf Message来构建RPC Server。 在服务器端实现,是和Spring Framework集成,核心类:

  • TProtobufProcessor:重写了TProcessor的实现, 从Thrift序列化的字节流中解析出调用的方法名。这个方法名被映射到Spring Bean容器中的Component名字,通过这个Bean名字来调用对应的Component的方法,完成服务调用。 比如
  • Controller: 这个接口即用来支持TProtobufProcessor调用的Component的基类,提供process接口,供其调用。
  • BaseController: Controller实现的公共基类,封装一些通用的异常处理。
  • RpcServerConfiguration: 用来支持将RPC Server注册到Zookeeper上以及启动Server的配置。 支持自动配置。

三、cocolian-rpc-client

和rpc-server相对应的客户端实现, 主要是提供一个Transport连接池,这是基于Apache Commons Pools实现的RPC 连接池。 ├── TransportManager 连接池接口
└── PooledTransport: 基于Apache Commons Pools 的连接池声明
└── AbstractTransportPool 实现基本的连接池接口
└──RefreshableTransportPool 支持按照一定的策略来更新链接的连接池
└──BasicTransportPool 最基本的round-robin轮询方式的可更新的链接池,即按照zk上注册的顺序,依次选择服务器。

四、cocolian-rpc-docker

提供一个支持rpc server的docker基础镜像。 注意:

  1. 这个image是基于centos来构建的。
  2. 预装oracle server jre。

注意: 这个版本支持jdk1.8.0_152版本,必须先下载这个版本,并解压缩后,放到src/main/docker下,目录为 src/main/docker/jdk1.8.0_152

TODO:

  1. 进一步优化base image, 删除不必要的模块。
  2. 增加监控和日志收集组件。

四、开发指南

1. 执行流程

  • 更新代码,如果使用的是从库,更新代码请使用git fetch upstream,详情请参考:Cocolian Wiki: GitHub Pull Request指南
  • 启动zookeeper, 使用zkServer start ,详情请参考:Apache Zookeeper安装指南
  • 打包构建 转到cocolian-id目录下执行mvn clean install -DskipTests=true
  • 执行start.sh 文件 打包成功之后转到 cocolian-id-generator 目录执行/target/bin 下的start.sh 文件, 启动id server
  • 运行TestIdService测试用例, 确认所有测试通过

2. 错误以及处理办法

  • 执行./start.sh 报错-bash: ./start.sh: Permission denied 权限不足,处理办法 chmod 777 start.sh, 或者bash start.sh
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].