Skip to content
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

(wip) Implement support for call credentials #26

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jdk:
- openjdk20
7 changes: 4 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<packaging>pom</packaging>

<artifactId>vertx-grpc-aggregator</artifactId>
<version>5.0.0-SNAPSHOT</version>
<version>4.4.4</version>

<properties>
<stack.version>5.0.0-SNAPSHOT</stack.version>
<stack.version>4.4.4</stack.version>
<grpc.version>1.50.2</grpc.version>
<protoc.version>3.21.12</protoc.version>
<protoc.version>3.23.1</protoc.version>
<doc.skip>true</doc.skip>
</properties>

Expand Down Expand Up @@ -63,6 +63,7 @@
<module>vertx-grpc-common</module>
<module>vertx-grpc-server</module>
<module>vertx-grpc-client</module>
<module>vertx-grpc-jwt-auth</module>
<module>vertx-grpc-context-storage</module>
<module>vertx-grpc-protoc-plugin2</module>
<module>vertx-grpc-it</module>
Expand Down
2 changes: 1 addition & 1 deletion vertx-grpc-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>io.vertx</groupId>
<artifactId>vertx-grpc-aggregator</artifactId>
<version>5.0.0-SNAPSHOT</version>
<version>4.4.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
9 changes: 9 additions & 0 deletions vertx-grpc-client/src/main/asciidoc/client.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,12 @@ handle the message encoding:

- when the message uses the response encoding, the message is sent as is
- when the message uses a different encoding, it will be encoded, e.g. compressed or uncompressed

=== Error Handling

A `{@link io.vertx.grpc.common.GrpcException}` may be throw and accessed via a `onFailure` handler. It may grant access to the response and the gRPC status via `{@link io.vertx.grpc.common.GrpcStatus}`.

[source,java]
----
{@link examples.GrpcClientExamples#errorHandling}
----
39 changes: 2 additions & 37 deletions vertx-grpc-client/src/main/java/examples/Empty.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions vertx-grpc-client/src/main/java/examples/GrpcClientExamples.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
import io.vertx.core.Future;
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpClientResponse;
import io.vertx.core.net.SocketAddress;
import io.vertx.docgen.Source;
import io.vertx.grpc.client.GrpcClient;
import io.vertx.grpc.client.GrpcClientChannel;
import io.vertx.grpc.client.GrpcClientRequest;
import io.vertx.grpc.client.GrpcClientResponse;
import io.vertx.grpc.common.GrpcException;
import io.vertx.grpc.common.GrpcMessage;
import io.vertx.grpc.common.GrpcStatus;
import io.vertx.grpc.common.ServiceName;

@Source
Expand Down Expand Up @@ -189,4 +192,18 @@ public void messageLevelAPI(GrpcClient client, Buffer protoHello, SocketAddress
});
});
}

public void errorHandling(GrpcClientRequest<HelloRequest, HelloReply> request) {
request.response().onSuccess(response -> {
Future<HelloReply> fut = response.last();
fut.onFailure(error -> {
if (error instanceof GrpcException) {
GrpcException grpcError = (GrpcException) error;
GrpcStatus status = grpcError.status();
HttpClientResponse httpResponse = grpcError.response();
}
});
});
}

}
39 changes: 2 additions & 37 deletions vertx-grpc-client/src/main/java/examples/HelloReply.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 2 additions & 37 deletions vertx-grpc-client/src/main/java/examples/HelloRequest.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 2 additions & 37 deletions vertx-grpc-client/src/main/java/examples/Item.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@

import io.grpc.CallOptions;
import io.grpc.ClientCall;
import io.grpc.Compressor;
import io.grpc.CompressorRegistry;
import io.grpc.MethodDescriptor;
import io.vertx.core.net.SocketAddress;

import java.util.concurrent.Executor;

/**
* Bridge a gRPC service with a {@link io.vertx.grpc.client.GrpcClient}.
*/
Expand All @@ -34,20 +30,7 @@ public GrpcClientChannel(GrpcClient client, SocketAddress server) {

@Override
public <RequestT, ResponseT> ClientCall<RequestT, ResponseT> newCall(MethodDescriptor<RequestT, ResponseT> methodDescriptor, CallOptions callOptions) {

String encoding = callOptions.getCompressor();

Compressor compressor;
if (encoding != null) {
compressor = CompressorRegistry.getDefaultInstance().lookupCompressor(encoding);
} else {
compressor = null;
}


Executor exec = callOptions.getExecutor();

return new VertxClientCall<>(client, server, exec, methodDescriptor, encoding, compressor);
return new VertxClientCall<>(client, server, methodDescriptor, callOptions, authority());
}

@Override
Expand Down
Loading