https://github.com/jiajunhuang/pasty
公司的项目用了 thrift,所以自己整 gRPC 来玩玩。以后就可以愉快的到处复制粘贴了。
感受:
- RPC 比 RESTful 好用多了。。。虽然 RESTful 更加跨平台
- protobuf 不能使用"原始类型"例如 string,int64 等作为 rpc 调用的参数。必需包装在 message 里。这一点 很蛋疼。对比起来 thrift 好用一些。
- thrift-compiler 老版本生成的 go 代码居然不能用,这是一个大坑。
- 据说 gRPC 的工具链比 thrift 丰富?例如监控等?
看看 pasty 的使用:
jiajun@idea ~: type p
p is /home/jiajun/golang/bin/p
jiajun@idea ~: echo "hello" > test.txt
jiajun@idea ~: p < test.txt
jiajun@idea ~: p -limit 1
file id 3 created at 2018-04-10 23:19:03 +0800 CST ==================
hello
file id 3 created at 2018-04-10 23:19:03 +0800 CST over ==================
jiajun@idea ~: p -limit 1 -hint=false
hello
jiajun@idea ~: echo "hello world" | p
jiajun@idea ~: p -limit 1 -hint=false
hello world
jiajun@idea ~: p -limit 2 -hint=false
hello world
hello
jiajun@idea ~: p -limit 2
file id 4 created at 2018-04-10 23:19:35 +0800 CST ==================
hello world
file id 4 created at 2018-04-10 23:19:35 +0800 CST over ==================
file id 3 created at 2018-04-10 23:19:03 +0800 CST ==================
hello
file id 3 created at 2018-04-10 23:19:03 +0800 CST over ==================