Comments (15)
小伙伴好呀,整体思路没有什么问题,如果想用压缩功能,你相当于要把server准备发出的内容做压缩、client接收到的每块内容做解压、然后server该怎么拆和client该怎么拼接都是你的逻辑~
1、如何利用srpc的压缩?
srpc在框架层已经帮你做好压缩/解压了,如果server和client双方都是SRPC的框架编译出来的,那么只需要server加上一行就可以进行压缩、而client会自动解压,你无需再做任何事情。
我们用tutorial-01/tutorial-02为例子:
tutorial-01的实现里加一行就行:
class ExampleServiceImpl : public Example::Service
{
public:
void Echo(EchoRequest *req, EchoResponse *resp, RPCContext *ctx) override
{
resp->set_message("Hi back");
ctx->set_compress_type(RPCCompressGzip); // 这里以Gzip为例子,srpc还支持其他压缩类型
printf("Server Echo()\nget_req:\n%s\nset_resp:\n%s\n",
req->DebugString().c_str(), resp->DebugString().c_str());
}
};
然后make && make tutorial,使用srpc_pb_server和srpc_pb_client跑起来就可以互通,而期间的数据是被压缩过的。
2、RPC和原先想要用的HTTP有什么区别?
你要基于srpc框架开发,所以会涉及IDL文件中的请求和回复格式,这个你可以参考./tutorial/echo_pb.proto,server就是实现这个Echo函数,client就是请求这个Echo函数。srpc框架可以发出HTTP请求,还是用tutorial01/tutorial02为例子,只需要把SRPCServer改成SRPCHttpServer、SRPCClient改成SRPCHttpClient,就可以跑起来了。
from srpc.
非常感谢您百忙之中给我回复问题,实际的情况是这样的:
服务端是部署的简单对象存储(其他组的服务,我只能进行http请求文件压缩传输,比如gzip,然后客户端收到响应进行解压缩后存储),不知道这样的情况下还能用到咱们srpc中的压缩功能吗
from srpc.
尊敬的作者大大,我看到了chanchan基于workflow写的wfrest里有个gzip压缩/解压缩的功能,我想可以先参考他的实现方法去做我说的事
from srpc.
你好。感觉这个问题,和rpc没有关系。用workflow发一个gzip压缩请求不就好了?收到回复也解压一下。感觉这个完全可以框架之外做。
另外,可以参考一下基于workflow的wfrest项目:https://github.com/wfrest/wfrest
wfrest是有处理压缩的,但主要做server。
from srpc.
wfrest里有个例子,使用workflow发gzip压缩的http请求,你可以看一下:
https://github.com/wfrest/wfrest/blob/main/docs/cn/compress.md
from srpc.
wfrest里有个例子,使用workflow发gzip压缩的http请求,你可以看一下: https://github.com/wfrest/wfrest/blob/main/docs/cn/compress.md
非常感谢您的回复,我当时就是看到srpc支持很多种压缩方式,所以才突发奇想有了这个issue,再次感谢您的帮助!
from srpc.
不客气的。你看看能不能解决你的需求。有任何别的问题随时沟通。
from srpc.
我发现在我回复之前,你已经找到了wfrest了😄
from srpc.
我发现在我回复之前,你已经找到了wfrest了😄
非常感谢您和22姐大晚上回复我!
workflow是个非常优秀的框架,借助它,让我这个小白能快速实现我想做的功能,后面我会努力学习其中的设计**!
from srpc.
哈哈哈。感谢使用。给workflow点个star再走哈。
from srpc.
必须的,全都点了一遍!
from srpc.
之前说的那个功能我已经实现了,速度还挺快,这个issue我就关啦
from srpc.
之前说的那个功能我已经实现了,速度还挺快,这个issue我就关啦
嗯嗯,能解决问题就太好了!你好像忘了star workflow项目😂。
from srpc.
之前说的那个功能我已经实现了,速度还挺快,这个issue我就关啦
嗯嗯,能解决问题就太好了!你好像忘了star workflow项目😂。
尴尬了啊,这回我点了。。。 😄
from srpc.
之前说的那个功能我已经实现了,速度还挺快,这个issue我就关啦
嗯嗯,能解决问题就太好了!你好像忘了star workflow项目😂。
尴尬了啊,这回我点了。。。 😄
使用愉快哈。有问题随时发issue!
from srpc.
Related Issues (20)
- crt detected that the application wrote to memory after end of heap buffer HOT 4
- 🎉 srpc tools: simple generator for building Workflow and SRPC projects
- cross compile problem HOT 12
- compile problem HOT 14
- srpc_generator.exe无法使用 HOT 3
- does one service support multi function HOT 7
- Android compile problem HOT 20
- MacOS下链接找不到protobuf HOT 9
- srpc搭建http服务时, 回包如何通过JsonPrintOptions设置打印格式 HOT 4
- 要求CMake找到一个由“Snappy”提供的包配置文件,但是 CMake没有找到。 HOT 6
- docs/wiki.md第二章图片有误 HOT 1
- Srpc无法正确生成官方hbase.thrift的srpc客户端 HOT 24
- Support in API testing tool linuxsuren/api-testing HOT 7
- srpc和workflow配合使用问题 HOT 19
- 在SRPCHttpServer上启用trace上报opentelemtry功能异常 HOT 6
- 关于 RPCBuffer 中 read_back 问题 HOT 3
- 关于 RPCBuffer::cut 和 BRPC 中的 attachment 使用的问题 HOT 2
- 是否计划支持linux io_uring? HOT 3
- SRPC性能测试问题 HOT 26
- client.Echo start multi thread,how can I start only one thread? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from srpc.