nyan233 / littlerpc Goto Github PK
View Code? Open in Web Editor NEW高性能/跨语言/轻量的玩具级RPC实现,致力提供高扩展性的API,您可以打造属于自己的RPC-Framework!
License: MIT License
高性能/跨语言/轻量的玩具级RPC实现,致力提供高扩展性的API,您可以打造属于自己的RPC-Framework!
License: MIT License
Selector
来接入各种负载均衡算法,主要兼容一致性hash,LittleRpc
目前的提供的API是同步模式的,虽然性能上也能满足需求,但是其后续请求响应时间可能受限于一次响应比较慢的调用,响应比较慢可能是因为传输的数据量比较大等原因,所以提供异步调用的API以用来减少这种情况,让其不会阻塞后续比较小数据量的调用。
目前设计的API原型
AsyncCall(processName string,args ...interface{}) (rep []interface{},err error)
RegisterCallBack(processName string,fn func(rep []interface{},err err error))
生成器也必须生成一套支持异步调用语义的接口与实现
type TestHybridInter interface {
Say(str sting) (string,error)
SayAsync(str string) error
RegisterSayCallBack(fn func(_ string,_ error))
}
主要优化使用到goroutine pool
代码的client
&server
优雅地打印堆栈信息以确定panic的原因, 最好还能像gin
那样判断panic
是携带的error
类型, 不同类型做不同的处理
instanceName Len
(4Byte) & methodName Len
(4 Byte) --> serviceName Len
(1 Byte)NArgs
(4 Byte) --> NArgs
(1 Byte)NMetaData
(4 Byte) --> NMetaData
(1 Byte)Scope CodecType
(1 Byte) & Scope EncoderType
(1 Byte) --> Delete (0 Byte)static length
: 18 Byte --> 3 Byte
type Parser interface {
Read(reader io.Reader) error
...
}
io.Reader
不能被阻塞, 否则会影响性能
旧的关于
error
定义和解析的API
相当不友好, 也只能使用Json Codec, 不是一个好的设计
新的错误应该符合以下几个条件
目前的实现的缺点
0
来定义Nil错误littlerpc
自动注入的error
UnmarshalError(data []byte,i interface{}) error
MarshalError(i interface{}) ([]byte,error)
Rep([]interface{})
中pxtor
能够生成符合新的API规范的代码现有的plugin
很难使用, bug
频出
LittleRpc/impl
中存放的是具体的client
&server
的具体实现,而其测试代码因为要同时用到client
&server
的API,不能将测试代码安排在client
&server
包中,所以被安排在了主目录下,但是在go test -v -cover ./...
执行完毕后,test包中每个测试项都被执行了,impl
中显示的覆盖率为%5.1
这显然是不正常的,在初步了解到了go test
覆盖率计算的-coverpkg
,也即测试的代码和被测试的代码不在同一个包中,我意识到要想保证正确的覆盖率,我需要一种新的测试方法。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.