1
1
/*
2
- * Copyright (c) 2019, 2022 Oracle and/or its affiliates.
2
+ * Copyright (c) 2019, 2023 Oracle and/or its affiliates.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
23
23
import io .helidon .grpc .server .GrpcRouting ;
24
24
import io .helidon .grpc .server .GrpcServer ;
25
25
import io .helidon .grpc .server .GrpcServerConfiguration ;
26
- import io .helidon .health .checks .HealthChecks ;
27
26
import io .helidon .logging .common .LogConfig ;
28
- import io .helidon .reactive . health . HealthSupport ;
29
- import io .helidon .reactive .webserver .Routing ;
30
- import io .helidon .reactive .webserver .WebServer ;
27
+ import io .helidon .nima . observe . ObserveFeature ;
28
+ import io .helidon .nima .webserver .WebServer ;
29
+ import io .helidon .nima .webserver .http . HttpRouting ;
31
30
32
31
/**
33
32
* A basic example of a Helidon gRPC server.
@@ -53,7 +52,7 @@ public static void main(String[] args) {
53
52
GrpcServerConfiguration serverConfig =
54
53
GrpcServerConfiguration .builder (config .get ("grpc" )).build ();
55
54
56
- GrpcServer grpcServer = GrpcServer .create (serverConfig , createRouting (config ));
55
+ GrpcServer grpcServer = GrpcServer .create (serverConfig , createGrpcRouting (config ));
57
56
58
57
// Try to start the server. If successful, print some info and arrange to
59
58
// print a message at shutdown. If unsuccessful, print the exception.
@@ -68,31 +67,18 @@ public static void main(String[] args) {
68
67
return null ;
69
68
});
70
69
71
- // add support for standard and gRPC health checks
72
- HealthSupport health = HealthSupport .builder ()
73
- .add (HealthChecks .healthChecks ())
74
- .addLiveness (grpcServer .healthChecks ())
75
- .build ();
70
+ WebServer server = WebServer .builder ()
71
+ .routing (Server ::routing )
72
+ .start ();
76
73
77
- // start web server with health endpoint
78
- Routing routing = Routing .builder ()
79
- .register (health )
80
- .build ();
74
+ System .out .println ("WEB server is up! http://localhost:" + server .port ());
75
+ }
81
76
82
- WebServer .create (routing , config .get ("webserver" ))
83
- .start ()
84
- .thenAccept (s -> {
85
- System .out .println ("HTTP server is UP! http://localhost:" + s .port ());
86
- s .whenShutdown ().thenRun (() -> System .out .println ("HTTP server is DOWN. Good bye!" ));
87
- })
88
- .exceptionally (t -> {
89
- System .err .println ("Startup failed: " + t .getMessage ());
90
- t .printStackTrace (System .err );
91
- return null ;
92
- });
77
+ private static void routing (HttpRouting .Builder routing ) {
78
+ routing .addFeature (ObserveFeature .create ());
93
79
}
94
80
95
- private static GrpcRouting createRouting (Config config ) {
81
+ private static GrpcRouting createGrpcRouting (Config config ) {
96
82
GreetService greetService = new GreetService (config );
97
83
GreetServiceJava greetServiceJava = new GreetServiceJava (config );
98
84
0 commit comments