Add gRPC reverse proxy server example#5722
Conversation
387a425 to
effa17f
Compare
effa17f to
8b01b1a
Compare
- style: Apply checkStyle
- fix typo
8b01b1a to
774b34f
Compare
|
Could you check the build failures and make sure the tests are not flaky? |
- fix: Modify armeria server port
| testImplementation libs.awaitility | ||
| testImplementation libs.junit5.jupiter.api | ||
| testImplementation libs.protobuf.java.util | ||
| testImplementation libs.testcontainers.junit.jupiter |
There was a problem hiding this comment.
Please create a separate project for the example you're writing. Don't make an example do more than one thing.
There was a problem hiding this comment.
Well, am I right to understand?
Are you telling me to create and use a grpc-reverse-proxy project in the sample directory?
| @BeforeAll | ||
| static void startServer() { | ||
| server = Server.builder() | ||
| .http(18080) |
There was a problem hiding this comment.
Please use an ephemeral port to avoid port collision
|
|
||
| @Container | ||
| private static GenericContainer<?> envoy = new GenericContainer<>("envoyproxy/envoy:v1.22.0") | ||
| .withExposedPorts(9090) |
There was a problem hiding this comment.
Please use a random unused port to avoid port collision as much as possible. Use PortUtil.unusedTcpPort.
- Remove reverse proxy in grpc project - Add reverse proxy project - Add reverse proxy example
- Apply checkstyle
|
It does not appear to be a problem caused by overlapping ports. |
- Modify envoy start, stop async
- Modify timeout
- Modify envoy start, stop
|
build-self-hosted-unsafe-jdk-21-snapshot-blockhound I don't think there's a docker on the ci server
|
- Add try/catch CompletionException
- Apply checkstyle
| private static final int serverPort = PortUtil.unusedTcpPort(); | ||
| private static final int backendServerPort = PortUtil.unusedTcpPort(); |
There was a problem hiding this comment.
In an example, we should use the fixed ports. I'd expect tests use unused random ports though.
There was a problem hiding this comment.
I modified it to use a fixed port.
| @BeforeAll | ||
| static void startServer() { | ||
| server = Server.builder() | ||
| .http(serverPort) |
There was a problem hiding this comment.
Specify 0 and let the OS choose the port number?
- test: Using server port 0
- fix: Modify default port
- test: Apply checkstyle
|
Pushed some small commits 🙇 Let me know if any changes don't make sense |
minwoox
left a comment
There was a problem hiding this comment.
Looks great, thanks!
Could you also run this script to see if everything works correctly?
https://github.com/line/armeria-examples/blob/main/update-examples.sh
You might run this command: (I supposed armeria and armeria-examples are in the same parent directory)
./update-examples.sh 1.29.0 ../armeria
| class GrpcEnvoyProxyTest { | ||
|
|
||
| // the port envoy binds to within the container | ||
| private static final int envoyPort = 10000; |
There was a problem hiding this comment.
nit:
| private static final int envoyPort = 10000; | |
| private static final int ENVOY_PORT = 10000; |
| private static Server startBackendServer(int serverPort) { | ||
| return Server.builder() | ||
| .http(serverPort) | ||
| .service(GrpcService.builder() | ||
| .addService(new HelloService()) | ||
| .build()) | ||
| .build(); | ||
| } |
There was a problem hiding this comment.
nit: style
| private static Server startBackendServer(int serverPort) { | |
| return Server.builder() | |
| .http(serverPort) | |
| .service(GrpcService.builder() | |
| .addService(new HelloService()) | |
| .build()) | |
| .build(); | |
| } | |
| private static Server startBackendServer(int serverPort) { | |
| return Server.builder() | |
| .http(serverPort) | |
| .service(GrpcService.builder() | |
| .addService(new HelloService()) | |
| .build()) | |
| .build(); | |
| } |
- Apply code style - Add dependencies - Modify variable name
- Modify variable name
| address: | ||
| socket_address: | ||
| address: host.testcontainers.internal | ||
| address: host.docker.internal |
There was a problem hiding this comment.
host.docker.internal doesn't work on Linux. I think we should revert this change.
See envoyproxy/java-control-plane#303
There was a problem hiding this comment.
I was merging because of a crash, but I forgot the file. I fixed it!
- Change host
This script is not working properly. The following error occurs |
Let me see what happened. 😉 |
It works correctly. The problem was just that we needed to convert the It will be handled when we release the next version so you don't have to worry about it. 😉 |
|
Rather, I think learned a lot. Thank you. 😄 |
ikhoon
left a comment
There was a problem hiding this comment.
Looks a useful example! 🙇♂️🙇♂️

Motivation:
Add gRPC reverse proxy server example
Modifications:
Add gRPC reverse proxy server example with testcontainers.
Result: