-
Notifications
You must be signed in to change notification settings - Fork 914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
examples/grpc/src/test/java/example/armeria/grpc/GrpcReverseProxyServerTest.java
Outdated
Show resolved
Hide resolved
examples/grpc/build.gradle
Outdated
@@ -16,6 +16,7 @@ dependencies { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified it to use a fixed port.
@BeforeAll | ||
static void startServer() { | ||
server = Server.builder() | ||
.http(serverPort) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specify 0 and let the OS choose the port number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified it to use port 0.
ce6ab18
- 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -48,5 +48,5 @@ static_resources: | |||
- endpoint: | |||
address: | |||
socket_address: | |||
address: host.testcontainers.internal | |||
address: host.docker.internal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. 😉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot, @eottabom! 😄
Rather, I think learned a lot. Thank you. 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks a useful example! 🙇♂️🙇♂️
Motivation:
Add gRPC reverse proxy server example
Modifications:
Add gRPC reverse proxy server example with testcontainers.
Result: