Search in sources :

Example 1 with StringMessage

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() + "'");
}
Also used : StringMessage(io.helidon.grpc.examples.common.Strings.StringMessage)

Example 2 with StringMessage

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)));
}
Also used : StringMessage(io.helidon.grpc.examples.common.Strings.StringMessage) JsonObject(jakarta.json.JsonObject) StringService(services.StringService) Test(org.junit.jupiter.api.Test)

Example 3 with StringMessage

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 + "'");
    }
}
Also used : StringMessage(io.helidon.grpc.examples.common.Strings.StringMessage)

Example 4 with StringMessage

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() + "'");
    }
}
Also used : StringMessage(io.helidon.grpc.examples.common.Strings.StringMessage)

Aggregations

StringMessage (io.helidon.grpc.examples.common.Strings.StringMessage)4 JsonObject (jakarta.json.JsonObject)1 Test (org.junit.jupiter.api.Test)1 StringService (services.StringService)1