use of io.helidon.grpc.examples.common.Strings.StringMessage in project helidon by oracle.
the class StringClient method blockingUnary.
/**
* Call the unary {@code Upper} method using a blocking call.
*
* @param client the StringService {@link GrpcServiceClient}
*/
public static void blockingUnary(GrpcServiceClient client) {
StringMessage upperResonse = client.blockingUnary("Upper", inputMsg);
System.out.println("Blocking Upper response: '" + upperResonse.getText() + "'");
}
use of io.helidon.grpc.examples.common.Strings.StringMessage in project helidon by oracle.
the class MetricsTest method shouldHaveTimerMetric.
/**
* Verify that the StringService split method has the timer metric.
*/
@Test
public void shouldHaveTimerMetric() {
JsonObject json = getMetrics();
JsonObject timer = json.getJsonObject(StringService.class.getName() + ".split");
assertThat(timer, is(notNullValue()));
int count = timer.getInt("count");
int min = timer.getInt("min");
assertThat(count, is(0));
assertThat(min, is(0));
Iterator<StringMessage> iterator = stringStub.split(StringMessage.newBuilder().setText("A B C").build());
while (iterator.hasNext()) {
iterator.next();
}
json = getMetrics();
timer = json.getJsonObject(StringService.class.getName() + ".split");
assertThat(timer, is(notNullValue()));
count = timer.getInt("count");
min = timer.getInt("min");
assertThat(count, is(1));
assertThat(min, is(not(0)));
}
use of io.helidon.grpc.examples.common.Strings.StringMessage in project helidon by oracle.
the class StringClient method serverStreaming.
/**
* Call the server streaming {@code Split} method using an async call.
*
* @param client the StringService {@link GrpcServiceClient}
* @throws java.lang.Exception if the call fails
*/
public static void serverStreaming(GrpcServiceClient client) throws Exception {
String stringToSplit = "A B C D E";
FutureStreamingObserver responses = new FutureStreamingObserver();
StringMessage request = StringMessage.newBuilder().setText(stringToSplit).build();
client.serverStreaming("Split", request, responses);
// wait for the call to complete
List<String> words = responses.get();
for (String word : words) {
System.out.println("Response from async Split: '" + word + "'");
}
}
use of io.helidon.grpc.examples.common.Strings.StringMessage in project helidon by oracle.
the class StringClient method serverStreamingBlocking.
/**
* Call the server streaming {@code Split} method using a blocking call.
*
* @param client the StringService {@link GrpcServiceClient}
*/
public static void serverStreamingBlocking(GrpcServiceClient client) {
String stringToSplit = "A B C D E";
StringMessage request = StringMessage.newBuilder().setText(stringToSplit).build();
Iterator<StringMessage> iterator = client.blockingServerStreaming("Split", request);
while (iterator.hasNext()) {
StringMessage response = iterator.next();
System.out.println("Response from blocking Split: '" + response.getText() + "'");
}
}
Aggregations