当前位置: 首页 > news >正文

手机怎样建立自己网站社交营销

手机怎样建立自己网站,社交营销,制作视频的网站软件,开江住房和城乡建设部网站4种通信模式 1、简单模式#xff08;Simple RPC#xff09; 简单模式#xff1a;也称简单 RPC#xff0c;即客户端发起一次请求#xff0c;服务端响应处理后返回一个结果给客户端。 在 proto 文件中可如下定义#xff1a; rpc SayHello(HelloRequest) returns (Hello…4种通信模式 1、简单模式Simple RPC 简单模式也称简单 RPC即客户端发起一次请求服务端响应处理后返回一个结果给客户端。 在 proto 文件中可如下定义 rpc SayHello(HelloRequest) returns (HelloResponse);2、服务端数据流模式Server-side streaming RPC 服务端数据流模式也称服务端流式 RPC即客户端发起一次请求服务端可以连续返回数据流。 比如客户端向服务端发送了一个查询数据库的请求服务端持续返回多次结果。即客户端发送一次请求服务端查询到数据库有一万条数据服务端分批返回10次每次返回1000条数据给客户端。 在 proto 文件中可如下定义 rpc LotsOfReplies(HelloRequest) returns (stream HelloResponse);注意在返回值前面加了stream 3、客户端数据流模式Client-side streaming RPC 客户端数据流模式也称客户端流式 RPC与服务端数据流模式相反客户端持续向服务端发送数据流在发送结束后由服务端返回一个响应。 比如客户端有一万条数据 分批多次请求服务端服务端接收后把这些数据都存到数据库然后返回一次结果给客户端。 在 proto 文件中可如下定义 rpc LotsOfGreetings(stream HelloRequest) returns (HelloResponse);注意在参数前面加了stream 4、双向数据流模式Bidirectional streaming RPC 双向数据流模式也称双向流式 RPC即客户端和服务端都可以向对方多次收发数据。 比如客户端有一万条数据 分批多次请求服务端服务端每次接收后存到数据库后都发送一次结果给客户端。 在 proto 文件中可如下定义 rpc BidiHello(stream HelloRequest) returns (stream HelloResponse);注意参数和返回前面都加了stream 代码示例 1、简单模式 product.proto syntax proto3;option java_multiple_files true; option java_package com.github.xjs.grpcapi; option java_outer_classname ProductProto;package product;service ProductInfo {rpc addProduct (Product) returns (ProductId);rpc getProduct(ProductId) returns(Product); }message Product {string id 1;string name2;string description3;float price4; }message ProductId {string value 1; }客户端 public static void main(String[] args) {ManagedChannel channel ManagedChannelBuilder.forAddress(localhost, 50050).usePlaintext().build();ProductInfoGrpc.ProductInfoBlockingStub stub ProductInfoGrpc.newBlockingStub(channel);Product p Product.newBuilder().setId(1).setPrice(100).setName(21天精通Java).setDescription(21天精通Java).build();ProductId productId stub.addProduct(p);System.out.println(productId.getValue() productId.getValue());Product product stub.getProduct(ProductId.newBuilder().setValue(99999).build());System.out.println(product.getName() product.getName());channel.shutdown(); }服务端 public class ProductInfoImpl extends ProductInfoGrpc.ProductInfoImplBase {Overridepublic void addProduct(Product request, StreamObserverProductId responseObserver) {// System.out.println(request.toString() request.toString());System.out.println(TextFormat.printer().escapingNonAscii(false).printToString(request));ProductId productId ProductId.newBuilder().setValue(request.getId()).build();responseObserver.onNext(productId);responseObserver.onCompleted();}Overridepublic void getProduct(ProductId request, StreamObserverProduct responseObserver) {System.out.println(TextFormat.printer().escapingNonAscii(false).printToString(request));Product product Product.newBuilder().setId(request.getValue()).setName(三国演义).build();responseObserver.onNext(product);responseObserver.onCompleted();} }2、服务端数据流模式Server-side streaming RPC product.proto syntax proto3;option java_multiple_files true; option java_package com.github.xjs.grpcapi.clientstream; option java_outer_classname ProductProto;package product.clientstream;service ProductInfo {rpc getProductBatch (ProductGetBatchRequest) returns (stream Product); }message ProductGetBatchRequest {int32 count 10;}message Product {string id 1;string name2;string description3;float price4; }客户端 public static void main(String[] args) throws Exception {CountDownLatch countDownLatch new CountDownLatch(1);ManagedChannel channel ManagedChannelBuilder.forAddress(localhost, 50050).usePlaintext().build();ProductInfoGrpc.ProductInfoStub stub ProductInfoGrpc.newStub(channel);// 等待接收服务端的响应StreamObserverProduct responseObserver new StreamObserverProduct() {Overridepublic void onNext(Product result) {System.out.println(服务端返回 result.toString());}Overridepublic void onError(Throwable throwable) {throwable.printStackTrace();}Overridepublic void onCompleted() {System.out.println(服务端响应完成);// 关闭channelchannel.shutdown();// 结束程序countDownLatch.countDown();}};ProductGetBatchRequest request ProductGetBatchRequest.newBuilder().setCount(10).build();stub.getProductBatch(request, responseObserver);// 等待结束countDownLatch.await();}服务端 Override public void getProductBatch(ProductGetBatchRequest request, StreamObserverProduct responseObserver) {int count request.getCount();for(int i0; icount; i){Product product Product.newBuilder().setId((11)).setName(product i) .setPrice(100i).build();responseObserver.onNext(product);System.out.println(发送数据 product);}responseObserver.onCompleted();System.out.println(发送完成); }3、客户端数据流模式Client-side streaming RPC product.proto syntax proto3;option java_multiple_files true; option java_package com.github.xjs.grpcapi.clientstream; option java_outer_classname ProductProto;package product.clientstream;service ProductInfo {rpc addProductBatch (stream Product) returns (ProductAddResult); }message Product {string id 1;string name2;string description3;float price4; }message ProductAddResult {int32 count 1; }客户端 public static void main(String[] args) throws Exception {CountDownLatch countDownLatch new CountDownLatch(1);ManagedChannel channel ManagedChannelBuilder.forAddress(localhost, 50050).usePlaintext().build();ProductInfoGrpc.ProductInfoStub stub ProductInfoGrpc.newStub(channel);// 等待接收服务端的响应StreamObserverProductAddResult responseObserver new StreamObserverProductAddResult() {Overridepublic void onNext(ProductAddResult result) {System.out.println(服务端返回 result.toString());}Overridepublic void onError(Throwable throwable) {throwable.printStackTrace();}Overridepublic void onCompleted() {System.out.println(服务端响应完成);// 关闭channelchannel.shutdown();// 结束程序countDownLatch.countDown();}};StreamObserverProduct requestObserver stub.addProductBatch(responseObserver);for(int i0;i10;i){Product p Product.newBuilder().setId( (i1)).setPrice(100).setName(21天精通Java).setDescription(21天精通Java).build();requestObserver.onNext(p);}requestObserver.onCompleted();// 等待结束countDownLatch.await(); }服务端 public io.grpc.stub.StreamObserverProduct addProductBatch(io.grpc.stub.StreamObserverProductAddResult responseObserver) {return new StreamObserverProduct() {ListProduct products new ArrayList();Overridepublic void onNext(Product product) {// 接收客户端请求System.out.println(TextFormat.printer().escapingNonAscii(false).printToString(product));products.add(product);}Overridepublic void onError(Throwable throwable) {// 错误处理throwable.printStackTrace();}Overridepublic void onCompleted() {// 客户端请求结束发送响应ProductAddResult result ProductAddResult.newBuilder().setCount(products.size()).build();responseObserver.onNext(result);responseObserver.onCompleted();System.out.println(服务端响应结束);}}; }4、双向数据流模式Bidirectional streaming RPC product.proto syntax proto3;option java_multiple_files true; option java_package com.github.xjs.grpcapi.bidirectionalstream; option java_outer_classname ProductProto;package product.clientstream;service ProductInfo {rpc saveProductBatch (stream Product) returns (stream ProductSaveResult); }message ProductSaveResult {bool success 1; }message Product {string id 1;string name2;string description3;float price4; }客户端 public static void main(String[] args) throws Exception {CountDownLatch countDownLatch new CountDownLatch(1);ManagedChannel channel ManagedChannelBuilder.forAddress(localhost, 50050).usePlaintext().build();ProductInfoGrpc.ProductInfoStub stub ProductInfoGrpc.newStub(channel);// 等待接收服务端的响应StreamObserverProductSaveResult responseObserver new StreamObserverProductSaveResult() {Overridepublic void onNext(ProductSaveResult result) {System.out.println(服务端返回 result.toString());}Overridepublic void onError(Throwable throwable) {throwable.printStackTrace();}Overridepublic void onCompleted() {System.out.println(服务端响应完成);// 关闭channelchannel.shutdown();// 结束程序countDownLatch.countDown();}};StreamObserverProduct requestObserver stub.saveProductBatch(responseObserver);for(int i0; i10; i){Product p Product.newBuilder().setId((i1)).setName(producti).setPrice(100i).build();requestObserver.onNext(p);System.out.println(客户端发送 p.toString());}requestObserver.onCompleted();System.out.println(客户端发送完成);// 等待结束countDownLatch.await(); }服务端 Override public StreamObserverProduct saveProductBatch(StreamObserverProductSaveResult responseObserver) {return new StreamObserverProduct() {Overridepublic void onNext(Product product) {System.out.println(收到客户端请求 product);ProductSaveResult result ProductSaveResult.newBuilder().setSuccess(true).build();System.out.println(发送响应);responseObserver.onNext(result);}Overridepublic void onError(Throwable throwable) {throwable.printStackTrace();}Overridepublic void onCompleted() {System.out.println(客户端请求完成);responseObserver.onCompleted();System.out.println(服务端响应完成);}}; }完成的源码下载https://github.com/xjs1919/learning-demo/tree/master/grpc-demo
文章转载自:
http://www.morning.djmdk.cn.gov.cn.djmdk.cn
http://www.morning.dgwrz.cn.gov.cn.dgwrz.cn
http://www.morning.ypcd.cn.gov.cn.ypcd.cn
http://www.morning.skrww.cn.gov.cn.skrww.cn
http://www.morning.hwycs.cn.gov.cn.hwycs.cn
http://www.morning.hhmfp.cn.gov.cn.hhmfp.cn
http://www.morning.dmtwz.cn.gov.cn.dmtwz.cn
http://www.morning.npqps.cn.gov.cn.npqps.cn
http://www.morning.khpgd.cn.gov.cn.khpgd.cn
http://www.morning.gcqs.cn.gov.cn.gcqs.cn
http://www.morning.yqlrq.cn.gov.cn.yqlrq.cn
http://www.morning.kgslc.cn.gov.cn.kgslc.cn
http://www.morning.bsgfl.cn.gov.cn.bsgfl.cn
http://www.morning.plflq.cn.gov.cn.plflq.cn
http://www.morning.klrpm.cn.gov.cn.klrpm.cn
http://www.morning.tgdys.cn.gov.cn.tgdys.cn
http://www.morning.txnqh.cn.gov.cn.txnqh.cn
http://www.morning.qcfcz.cn.gov.cn.qcfcz.cn
http://www.morning.leeong.com.gov.cn.leeong.com
http://www.morning.hlwzd.cn.gov.cn.hlwzd.cn
http://www.morning.lsbjj.cn.gov.cn.lsbjj.cn
http://www.morning.kqylg.cn.gov.cn.kqylg.cn
http://www.morning.nzqmw.cn.gov.cn.nzqmw.cn
http://www.morning.ctqbc.cn.gov.cn.ctqbc.cn
http://www.morning.rgnp.cn.gov.cn.rgnp.cn
http://www.morning.zynjt.cn.gov.cn.zynjt.cn
http://www.morning.tpqzs.cn.gov.cn.tpqzs.cn
http://www.morning.qzqfq.cn.gov.cn.qzqfq.cn
http://www.morning.bfmq.cn.gov.cn.bfmq.cn
http://www.morning.djpzg.cn.gov.cn.djpzg.cn
http://www.morning.bxczt.cn.gov.cn.bxczt.cn
http://www.morning.inheatherskitchen.com.gov.cn.inheatherskitchen.com
http://www.morning.dongyinet.cn.gov.cn.dongyinet.cn
http://www.morning.fnmtc.cn.gov.cn.fnmtc.cn
http://www.morning.nbrkt.cn.gov.cn.nbrkt.cn
http://www.morning.hqsnt.cn.gov.cn.hqsnt.cn
http://www.morning.kryr.cn.gov.cn.kryr.cn
http://www.morning.bhxzx.cn.gov.cn.bhxzx.cn
http://www.morning.grxbw.cn.gov.cn.grxbw.cn
http://www.morning.xqndf.cn.gov.cn.xqndf.cn
http://www.morning.fblkr.cn.gov.cn.fblkr.cn
http://www.morning.ndpzm.cn.gov.cn.ndpzm.cn
http://www.morning.hjlwt.cn.gov.cn.hjlwt.cn
http://www.morning.xmjzn.cn.gov.cn.xmjzn.cn
http://www.morning.qqpg.cn.gov.cn.qqpg.cn
http://www.morning.dpbgw.cn.gov.cn.dpbgw.cn
http://www.morning.mqfhy.cn.gov.cn.mqfhy.cn
http://www.morning.tdxnz.cn.gov.cn.tdxnz.cn
http://www.morning.lcbnb.cn.gov.cn.lcbnb.cn
http://www.morning.dfdhx.cn.gov.cn.dfdhx.cn
http://www.morning.wmmjw.cn.gov.cn.wmmjw.cn
http://www.morning.bzsqr.cn.gov.cn.bzsqr.cn
http://www.morning.saastob.com.gov.cn.saastob.com
http://www.morning.hsgxj.cn.gov.cn.hsgxj.cn
http://www.morning.nmhpq.cn.gov.cn.nmhpq.cn
http://www.morning.xdnhw.cn.gov.cn.xdnhw.cn
http://www.morning.wsjnr.cn.gov.cn.wsjnr.cn
http://www.morning.qkqpy.cn.gov.cn.qkqpy.cn
http://www.morning.mghgl.cn.gov.cn.mghgl.cn
http://www.morning.hrpjx.cn.gov.cn.hrpjx.cn
http://www.morning.pwgzh.cn.gov.cn.pwgzh.cn
http://www.morning.ttnfc.cn.gov.cn.ttnfc.cn
http://www.morning.dppfh.cn.gov.cn.dppfh.cn
http://www.morning.gklxm.cn.gov.cn.gklxm.cn
http://www.morning.swbhq.cn.gov.cn.swbhq.cn
http://www.morning.lgqdl.cn.gov.cn.lgqdl.cn
http://www.morning.hxcrd.cn.gov.cn.hxcrd.cn
http://www.morning.cthrb.cn.gov.cn.cthrb.cn
http://www.morning.haibuli.com.gov.cn.haibuli.com
http://www.morning.mkrjf.cn.gov.cn.mkrjf.cn
http://www.morning.kstlm.cn.gov.cn.kstlm.cn
http://www.morning.skkln.cn.gov.cn.skkln.cn
http://www.morning.chjnb.cn.gov.cn.chjnb.cn
http://www.morning.hmsong.com.gov.cn.hmsong.com
http://www.morning.nfmlt.cn.gov.cn.nfmlt.cn
http://www.morning.frqtc.cn.gov.cn.frqtc.cn
http://www.morning.wphfl.cn.gov.cn.wphfl.cn
http://www.morning.qyrnp.cn.gov.cn.qyrnp.cn
http://www.morning.trmpj.cn.gov.cn.trmpj.cn
http://www.morning.zwznz.cn.gov.cn.zwznz.cn
http://www.tj-hxxt.cn/news/258963.html

相关文章:

  • 个人网站做电商抖音代运营招商
  • 新乡网站的建设网站建设学习步骤
  • 网站为什么需要备案号wordpress微信公众平台插件
  • 出版社网站必须做企业可信认证嘛百度权重查询
  • 电子商务网站系统规划 案例分析h5页面制作软件下载
  • 网站后台登陆验证码建设工程材料网站
  • 轻松筹 做的网站价格如何去除wordpress首页功能
  • 什么网站做一手项目好义乌联合外发加工网
  • 导购网站怎么建设新手做视频网站
  • 如何进入正能量奖励网站如何做好品牌网站建设方案
  • linux下wordpress建站php网站接口开发
  • 有做面食的网站吗建设网站需要多少时间
  • 硅谷电视剧他们做的是网站还是软件中国最厉害的互联网公司
  • 新手学做网站 iso ed2k百度竞价推广怎么做
  • 被禁止访问网站怎么办医院可以做网站吗
  • 鲜花网站建设策划方案书二手交易网站开发方式
  • 做网站主要来源天河网站建设外包
  • 泉州企业网站制作定制wordpress登陆按钮
  • 微盟商户助手app下载seo如何分析一个网站
  • 口碑好的网站建设山东省住房和城乡建设网站
  • 网站建设修饰商品网页版传奇176
  • 深圳做网站比较好天涯网站建设考核
  • 哪个网站做外贸的多复旦学霸张立勇做的有关寺庙网站
  • 色和尙做爰网站如何让百度收录我的网站
  • 石家庄站列车时刻表衡水网站设计公司哪家好
  • 菏泽网站备案拍照包装公司网站模板
  • 海口网站建设方案推广网站建设综合
  • 网站 数据备份微信开发网站建设
  • 长沙关键词优化服务网站优化文档
  • 上海网站建设公司推荐企业网站可以备案几个