use of com.hry.spring.grpc.mystream.SimpleFeature in project spring_boot by hryou0922.
the class HelloStreamClient method simpleRpc.
/**
* 一元服务调用
*/
public void simpleRpc(int num) {
logger.info("request simpleRpc: num={}", num);
Simple simple = Simple.newBuilder().setName("simpleRpc").setNum(num).build();
SimpleFeature feature;
try {
feature = blockingStub.simpleRpc(simple);
} catch (StatusRuntimeException e) {
logger.info("RPC failed: {0}", e.getStatus());
return;
}
logger.info("simpleRpc end called {}", feature);
}
use of com.hry.spring.grpc.mystream.SimpleFeature in project spring_boot by hryou0922.
the class HelloStreamClient method server2ClientRpc.
/**
* 阻塞服务器流
*/
public void server2ClientRpc(int num1, int num2) {
logger.info("request server2ClientRpc num1={}, num2={}", num1, num2);
Simple simple = Simple.newBuilder().setName("simple2" + num1).setNum(num1).build();
Simple simple2 = Simple.newBuilder().setName("simple2" + num2).setNum(num2).build();
SimpleList simpleList = SimpleList.newBuilder().addSimpleList(simple).addSimpleList(simple2).build();
Iterator<SimpleFeature> simpleFeatureIter = blockingStub.server2ClientRpc(simpleList);
for (int i = 1; simpleFeatureIter.hasNext(); i++) {
SimpleFeature feature = simpleFeatureIter.next();
logger.info("Result {} : {}", i, feature);
}
}
Aggregations