grpc-java/examples/example-hostname
Eric Anderson 44847bf4e9
Upgrade JUnit to 4.13.2
ExpectedException is deprecated, so I fixed the new warnings. However,
we are still using ExpectedException many places and had previously
supressed the warning. See
https://github.com/grpc/grpc-java/issues/7467 . I did not fix those
existing instances that had suppressed the warning, since it is
unrelated to the upgrade and we have been free to fix them at any time
since we dropped Java 7.
2023-01-20 09:33:11 -08:00
..
src examples: Swap to Channel/ServerCredentials API 2022-11-21 09:09:21 -08:00
BUILD.bazel examples: Add hostname example 2020-01-17 15:50:49 -08:00
README.md examples: Add hostname example 2020-01-17 15:50:49 -08:00
build.gradle Upgrade JUnit to 4.13.2 2023-01-20 09:33:11 -08:00
pom.xml Upgrade JUnit to 4.13.2 2023-01-20 09:33:11 -08:00
settings.gradle examples: Add hostname example 2020-01-17 15:50:49 -08:00

README.md

gRPC Hostname Example

The hostname example is a Hello World server whose response includes its hostname. It also supports health and reflection services. This makes it a good server to test infrastructure, like load balancing.

The example requires grpc-java to already be built. You are strongly encouraged to check out a git release tag, since there will already be a build of grpc available. Otherwise you must follow COMPILING.

Build the example

  1. Build the hello-world example client. See the examples README

  2. Build this server. From the grpc-java/examples/examples-hostname directory:

$ ../gradlew installDist

This creates the script build/install/hostname-server/bin/hostname-server that runs the example.

To run the hostname example, run:

$ ./build/install/hostname/bin/hostname-server

And in a different terminal window run the hello-world client:

$ ../build/install/examples/bin/hello-world-client

Maven

If you prefer to use Maven:

  1. Build the hello-world example client. See the examples README

  2. Run in this directory:

$ mvn verify
$ # Run the server (from the examples-hostname directory)
$ mvn exec:java -Dexec.mainClass=io.grpc.examples.hostname.HostnameServer
$ # In another terminal run the client (from the examples directory)
$ cd ..
$ mvn exec:java -Dexec.mainClass=io.grpc.examples.helloworld.HelloWorldClient

Bazel

If you prefer to use Bazel, run from the grpc-java/examples directory:

$ bazel build :hello-world-client example-hostname:hostname-server
$ # Run the server
$ ./bazel-bin/example-hostname/hostname-server
$ # In another terminal run the client
$ ./bazel-bin/hello-world-client