TOP

ScalaPB(2): 在scala中用gRPC实现微服务(三)
2019-08-15 00:11:45 】 浏览:94
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}") } }

 

 

 

 

 

 

 

 

 

 

 


ScalaPB(2): 在scala中用gRPC实现微服务(三) https://www.cppentry.com/bencandy.php?fid=90&id=229038

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