当前位置:网站首页>RPC - gRPC简单的demo - 学习/实践
RPC - gRPC简单的demo - 学习/实践
2022-07-04 03:54:00 【穿素白衫的少年】
1.应用场景
主要用于学习并且实践grpc,感受下,整个过程。 |
2.学习/操作
1.文档阅读
2.整理输出20220606 周一 成都公司 今天下午,学习并且实践了下,gRPC的Demo 回忆过程: php + nodeJS 前言根据自己的习惯喜欢,选择一个目录作为项目,如下是本人的工作目录
所有的脚本执行,自然要在上面目录下的某个字目录下进行。 1. php环境准备1.1 安装gprc,protobuf 的扩展sudo pecl install grpc protobuf gprc扩展安装截图 protobuf扩展安装截图 可以看到扩展被自动添加到了php.ini配置文件中,首行 检查扩展是否生效 1.2 安装 Composer两行命令即可
Mac 或 Linux 系统:--- 全局安装打开命令行窗口并执行如下命令将前面下载的 复制
1.3 安装protoc compiler直接下载二进制包,解压,将二进制可执行文件,添加到系统环境变量中 查看解压后的目录结构 加入到环境变量中 查看是否安装成功 1.4 安装grpc_php_plugin protoc插件这里使用cmake工具进行安装,但是需要先安装cmake clone grpc项目,并安装protoc 和 grpc_php_plugin插件 $ git clone -b RELEASE_TAG_HERE https://github.com/grpc/grpc
最终的目录结构 2. node环境准备2.1 安装nodeJS
3. 分别进入client和server的语言examples下,安装依赖
4. 启动服务端这里nodeJS由充当,而且一定要先启动服务端,否则,先启动客户端会出现报错,原因大家都懂~
运行服务器
从另一个终端运行客户端
这里的shell脚本,本质上也是执行node greeter_client.js 5. 启动客户端从examples/php目录中,运行 PHP 客户端:
本质上就是执行greeter_client.php脚本,这里要将文件中php cli 中 extension=grpc.so去掉,不然会报Warning,重复加载 -- 其实也在demo阶段,warning无关大雅。 另外,ERROR,是因为这里先启动了客户端。
至此,最简单的rpc调用完毕~ 后续补充 ... |
3.问题/补充
1. 先启动服务端,后启动客户端程序否则出现ERROR报错,如下:
解决办法: 1. 一个终端窗口中,先启动服务端程序
2. 另外一个终端窗口中,后启动客户端程序 正常输出 |
4.参考
参见上面文档列表 |
后续补充
...
边栏推荐
- What is context?
- Beipiao programmer, 20K monthly salary, 15W a year, normal?
- rac删除损坏的磁盘组
- Krypton saikr daily question - CTF
- Rhcsa 07 - user and group management
- 博朗与Virgil Abloh于2021年为纪念博朗品牌100周年而联合打造的“功能性艺术”将在博物馆展出Abloh作品期间首次亮相
- MIN_RTO 对话
- Intersection traffic priority, illustration of intersection traffic rules
- R语言中如何查看已安装的R包
- [microservices openfeign] two degradation methods of feign | fallback | fallbackfactory
猜你喜欢
Application scheme of Puyuan ds1000z series digital oscilloscope in communication principle experiment
Formatted text of Kivy tutorial (tutorial includes source code)
仿《游戏鸟》源码 手游发号评测开服开测合集专区游戏下载网站模板
2021 RSC | Drug–target affinity prediction using graph neural network and contact maps
Redis: hash type data operation command
Many founders of technology companies provided enterpriser first with a round C financing of up to US $158million to help it invest in the next generation of global innovators
Redis: operation command for collecting set type data
Architecture training graduation design + summary
苹果CMS仿西瓜视频大气响应式视频模板源码
[Yugong series] go teaching course 001 in July 2022 - Introduction to go language premise
随机推荐
2021 RSC | Drug–target affinity prediction using graph neural network and contact maps
Statistical genetics: Chapter 3, population genetics
Wechat brain competition answer applet_ Support the flow main belt with the latest question bank file
Redis: operation command for collecting set type data
How do good test / development programmers practice? Where to go
Architecture practice camp - graduation project of module 9 of phase 6
[cloud native] those lines of code that look awesome but have a very simple principle
Boutique website navigation theme whole station source code WordPress template adaptive mobile terminal
Wechat official account infinite callback authorization system source code
Talking about what a high-quality little red book copy needs to have
leetcode 121 Best Time to Buy and Sell Stock 买卖股票的最佳时机(简单)
[wechat applet] good looking carousel map component
Kivy教程之 07 组件和属性绑定实现按钮button点击修改label组件(教程含源码)
The five pictures tell you: why is there such a big gap between people in the workplace?
浅谈JVM的那些事
First knowledge of batch processing
MySQL JDBC编程
y55.第三章 Kubernetes从入门到精通 -- HPA控制器及metrics-server(二八)
Rhcsa 07 - user and group management
Unity资源路径