diff --git a/examples/grpc/basics/pom.xml b/examples/grpc/basics/pom.xml index 469148e38b1..f8340bdb666 100644 --- a/examples/grpc/basics/pom.xml +++ b/examples/grpc/basics/pom.xml @@ -39,6 +39,14 @@ + + io.helidon.nima.webserver + helidon-nima-webserver + + + io.helidon.nima.observe + helidon-nima-observe-health + io.helidon.examples.grpc helidon-examples-grpc-common diff --git a/examples/grpc/basics/src/main/java/io/helidon/grpc/examples/basics/Server.java b/examples/grpc/basics/src/main/java/io/helidon/grpc/examples/basics/Server.java index a42eba1aefc..f78094cf357 100644 --- a/examples/grpc/basics/src/main/java/io/helidon/grpc/examples/basics/Server.java +++ b/examples/grpc/basics/src/main/java/io/helidon/grpc/examples/basics/Server.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022 Oracle and/or its affiliates. + * Copyright (c) 2019, 2023 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,11 +23,10 @@ import io.helidon.grpc.server.GrpcRouting; import io.helidon.grpc.server.GrpcServer; import io.helidon.grpc.server.GrpcServerConfiguration; -import io.helidon.health.checks.HealthChecks; import io.helidon.logging.common.LogConfig; -import io.helidon.reactive.health.HealthSupport; -import io.helidon.reactive.webserver.Routing; -import io.helidon.reactive.webserver.WebServer; +import io.helidon.nima.observe.ObserveFeature; +import io.helidon.nima.webserver.WebServer; +import io.helidon.nima.webserver.http.HttpRouting; /** * A basic example of a Helidon gRPC server. @@ -53,7 +52,7 @@ public static void main(String[] args) { GrpcServerConfiguration serverConfig = GrpcServerConfiguration.builder(config.get("grpc")).build(); - GrpcServer grpcServer = GrpcServer.create(serverConfig, createRouting(config)); + GrpcServer grpcServer = GrpcServer.create(serverConfig, createGrpcRouting(config)); // Try to start the server. If successful, print some info and arrange to // print a message at shutdown. If unsuccessful, print the exception. @@ -68,31 +67,18 @@ public static void main(String[] args) { return null; }); - // add support for standard and gRPC health checks - HealthSupport health = HealthSupport.builder() - .add(HealthChecks.healthChecks()) - .addLiveness(grpcServer.healthChecks()) - .build(); + WebServer server = WebServer.builder() + .routing(Server::routing) + .start(); - // start web server with health endpoint - Routing routing = Routing.builder() - .register(health) - .build(); + System.out.println("WEB server is up! http://localhost:" + server.port()); + } - WebServer.create(routing, config.get("webserver")) - .start() - .thenAccept(s -> { - System.out.println("HTTP server is UP! http://localhost:" + s.port()); - s.whenShutdown().thenRun(() -> System.out.println("HTTP server is DOWN. Good bye!")); - }) - .exceptionally(t -> { - System.err.println("Startup failed: " + t.getMessage()); - t.printStackTrace(System.err); - return null; - }); + private static void routing(HttpRouting.Builder routing) { + routing.addFeature(ObserveFeature.create()); } - private static GrpcRouting createRouting(Config config) { + private static GrpcRouting createGrpcRouting(Config config) { GreetService greetService = new GreetService(config); GreetServiceJava greetServiceJava = new GreetServiceJava(config);