设为首页 加入收藏

TOP

ScalaPB(2): 在scala中用gRPC实现微服务(三)
2019-08-15 00:11:45 】 浏览:238
Tags:ScalaPB scala 中用 gRPC 实现 服务
uot;
LocalHost",50051) .usePlaintext(true) .build() //construct requestHelloService val greeter = ToBeGreeted() .withMsg("remote greetings!") .withPerson(ToBeGreeted.Person("mickey")) //async call val asyncStub: HelloWorldGrpc.HelloWorldStub = HelloWorldGrpc.stub(channel) val futResponse: Future[Greeting] = asyncStub.sayHello(greeter) import scala.concurrent.ExecutionContext.Implicits.global futResponse.foreach(greeting => println(greeting.message)) val greeter2 = ToBeGreeted(person = Some(Person("jacky")),msg = Some("how are you?")) //sync call val syncStub: HelloWorldGrpc.HelloWorldBlockingClient = HelloWorldGrpc.blockingStub(channel) val response: Greeting = syncStub.sayHello(greeter2) println(s"${response.message}") } }

 

 

 

 

 

 

 

 

 

 

 

首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇ScalaPB(3): gRPC streaming 下一篇ScalaPB(4): 通用跨系统protob..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目