-
Notifications
You must be signed in to change notification settings - Fork 1
feat(sdk): use connect-rpc
for GRPC
#244
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
base: main
Are you sure you want to change the base?
Conversation
ad65930
to
cb472ef
Compare
4ecb6f0
to
78442f2
Compare
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.
Pull Request Overview
This PR migrates the GRPC service calls to use connect‑rpc’s blocking APIs and updates buf configuration to v2, while also refactoring the token extraction in the GRPCAuthInterceptor for idiomatic Kotlin usage. Key changes include replacing asynchronous .get() calls with ResponseMessageKt.getOrThrow blocking calls, updating generated policy imports, and revising buf configuration files.
Reviewed Changes
Copilot reviewed 26 out of 32 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
sdk/Config.java | Replaced the deprecated policy.Value import with the generated version. |
sdk/Autoconfigure.java | Updated to use AttributesServiceClient with blocking calls and adjusted decoding. |
sdk/AddressNormalizer.java | Introduced a new utility for normalizing address URLs based on plaintext mode. |
sdk/buf.yaml & sdk/buf.gen.yaml | Upgraded configuration files to buf v2 with updated linting and plugin settings. |
examples/* | Modified service calls to use the blocking API with ResponseMessageKt.getOrThrow. |
Files not reviewed (6)
- examples/buf.gen.yaml: Language not supported
- examples/buf.yaml: Language not supported
- examples/pom.xml: Language not supported
- keys/kas-cert.pem: Language not supported
- pom.xml: Language not supported
- sdk/pom.xml: Language not supported
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.
Pull Request Overview
This PR refactors the GRPC client integration to use the connect-rpc library and updates buf configuration to v2 while adjusting address normalization logic. Key changes include:
- Replacing the legacy GRPC stub creation with a new AccessServiceClient using a blocking API.
- Upgrading buf configuration files and removing buf generation from the examples.
- Implementing address normalization with support for plaintext mode and leveraging a new AddressNormalizer utility.
Reviewed Changes
Copilot reviewed 29 out of 34 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
sdk/src/main/java/io/opentdf/platform/sdk/KASClient.java | Replaces GRPC stub creation and updates methods to use blocking calls with proper error handling via ResponseMessageKt.getOrThrow. |
sdk/src/main/java/io/opentdf/platform/sdk/Config.java | Updates import references to generated packages. |
sdk/src/main/java/io/opentdf/platform/sdk/Autoconfigure.java | Replaces asynchronous GRPC calls with blocking variants. |
sdk/src/main/java/io/opentdf/platform/sdk/AddressNormalizer.java | Introduces a new utility class for normalizing addresses based on plaintext mode. |
sdk/buf.yaml & sdk/buf.gen.yaml | Upgrades buf configuration to version v2 and adjusts generation options accordingly. |
examples/* | Updates examples to use blocking GRPC calls from connect-rpc with getOrThrow for error handling. |
Files not reviewed (5)
- examples/buf.gen.yaml: Language not supported
- examples/buf.yaml: Language not supported
- examples/pom.xml: Language not supported
- pom.xml: Language not supported
- sdk/pom.xml: Language not supported
Comments suppressed due to low confidence (1)
sdk/src/main/java/io/opentdf/platform/sdk/KASClient.java:254
- [nitpick] Consider renaming the variable 'req' (and the later 'request' reuse) to more descriptive names (e.g. 'rewrapRequestBuilder' and 'rewrapResponseRequest') to improve clarity in the unwrapNanoTDF method.
var req = RewrapRequest.newBuilder()
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.
Pull Request Overview
This PR updates the SDK to use connect-rpc for GRPC communication while also reorganizing the codebase to use generated service definitions instead of shipping test-only code. The key changes include replacing gRPC stubs with connect-rpc clients, updating buf configuration files to version v2 with new generation rules, and aligning example modules to use the new blocking API calls.
Reviewed Changes
Copilot reviewed 30 out of 35 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
sdk/src/main/java/io/opentdf/platform/sdk/KASClient.java | Migrates from gRPC channels to connect-rpc with updated blocking calls and error handling. |
sdk/src/main/java/io/opentdf/platform/sdk/Config.java | Updates import references and minor code cleanup. |
sdk/src/main/java/io/opentdf/platform/sdk/Autoconfigure.java | Replaces policy package imports with generated equivalents and updates service calls. |
sdk/src/main/java/io/opentdf/platform/sdk/AddressNormalizer.java | Introduces a new utility for normalizing addresses compatible with plaintext settings. |
sdk/buf.yaml and sdk/buf.gen.yaml | Upgrades configuration versions and adjusts generation options. |
examples/* | Updates example calls to use the new connect-rpc blocking API methods. |
Files not reviewed (5)
- examples/buf.gen.yaml: Language not supported
- examples/buf.yaml: Language not supported
- examples/pom.xml: Language not supported
- pom.xml: Language not supported
- sdk/pom.xml: Language not supported
Comments suppressed due to low confidence (2)
sdk/src/main/java/io/opentdf/platform/sdk/KASClient.java:105
- [nitpick] Consider using a unified error handling utility; here 'RequestHelper.getOrThrow' is used while other parts of the codebase use 'ResponseMessageKt.getOrThrow'.
resp = RequestHelper.getOrThrow(req);
sdk/src/main/java/io/opentdf/platform/sdk/KASClient.java:261
- [nitpick] Consider using consistent variable naming for request objects. The variable 'req' is renamed to 'request' in close proximity, which might be confusing.
var request = getStub(keyAccess.url).rewrapBlocking(req, Collections.emptyMap()).execute();
|
TokenSource
out ofGRPCAuthInterceptor
. This lets us keep the token code in Java while using idiomatic Kotlin stuff to modify the requestbuf changes
buf
tov2
buf
generation fromexamples
. Unless we need to call tagging or something we already have everything we need insdk
dependency updates
okhttp3
depends on version1.9
of Kotlin.connect-rpc
depends on version2.1
but it's ok forokhttp3
to use a later version so we exclude itskotlin
dependency.connect-rpc
depends onokhttp3:4.12.0
we downgrade our dependency instead of forcing connect to do a major version bumpaddress normalization
<hostname>:<port>
addresses arehttp
URLs, without plaintext mode they becomehttps
URLs.http://example.org:80
tohttps://example.org:80
. This is similar to what would have happened before; we'd use TLS to connect toexample.org:80