Skip to content

feat(sdk)!: switch to connect-rpc for GRPC - #244

Merged
mkleene merged 62 commits into
mainfrom
feature/connect-rpc
May 9, 2025
Merged

feat(sdk)!: switch to connect-rpc for GRPC#244
mkleene merged 62 commits into
mainfrom
feature/connect-rpc

Conversation

@mkleene

@mkleenemkleene commented Apr 21, 2025

Copy link
Copy Markdown
Contributor
  • pull a TokenSource out of GRPCAuthInterceptor. This lets us keep the token code in Java while using idiomatic Kotlin stuff to modify the request

buf changes

  • upgrade buf to v2
  • remove buf generation from examples. Unless we need to call tagging or something we already have everything we need in sdk
  • move the service definitions to test so that we don't ship things that we are just using for tests

dependency updates

address normalization

  • We take the scheme (http vs https) from the value of usePlaintext
  • If a port is specified we use it. If not we default based on the value of usePlaintext (true -> 80, false -> 443)

@mkleenemkleene changed the title Feature/connect rpcfeat(sdk): use connect-rpc for GRPCApr 21, 2025
@mkleene
mkleeneforce-pushed the feature/connect-rpc branch from ad65930 to cb472efCompareApril 21, 2025 19:33
@mkleene
mkleene marked this pull request as ready for review April 21, 2025 21:46
@mkleene
mkleene requested a review from a team as a code ownerApril 21, 2025 21:46

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
sdk/src/main/java/io/opentdf/platform/sdk/KASClient.javaMigrates from gRPC channels to connect-rpc with updated blocking calls and error handling.
sdk/src/main/java/io/opentdf/platform/sdk/Config.javaUpdates import references and minor code cleanup.
sdk/src/main/java/io/opentdf/platform/sdk/Autoconfigure.javaReplaces policy package imports with generated equivalents and updates service calls.
sdk/src/main/java/io/opentdf/platform/sdk/AddressNormalizer.javaIntroduces a new utility for normalizing addresses compatible with plaintext settings.
sdk/buf.yaml and sdk/buf.gen.yamlUpgrades 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();

@mkleenemkleene changed the title feat(sdk): use connect-rpc for GRPCfeat!(sdk): use connect-rpc for GRPCMay 7, 2025
@mkleenemkleene changed the title feat!(sdk): use connect-rpc for GRPCfeat(sdk)!: use connect-rpc for GRPCMay 7, 2025
@mkleenemkleene changed the title feat(sdk)!: use connect-rpc for GRPCfeat(sdk)!: switch to connect-rpc for GRPCMay 7, 2025
dmihalcik-virtru
dmihalcik-virtru previously approved these changes May 8, 2025
Comment threadsdk/src/main/java/io/opentdf/platform/sdk/AddressNormalizer.java Outdated
Comment threadsdk/src/main/java/io/opentdf/platform/sdk/AddressNormalizer.java Outdated
Comment threadsdk/src/main/java/io/opentdf/platform/sdk/KASClient.java Outdated
Comment threadsdk/src/main/java/io/opentdf/platform/sdk/KASClient.java Outdated
Comment threadsdk/src/main/java/io/opentdf/platform/sdk/KASClient.java Outdated
@mkleene
mkleene requested a review from CopilotMay 8, 2025 19:28

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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 client implementation to use connect‑rpc along with several dependency and configuration updates. Key changes include:

  • Replacing gRPC channel and stub creation with OkHttpClient and ProtocolClient.
  • Upgrading buf configuration to v2 and updating code generation settings.
  • Adjusting address normalization logic and updating example usages to call new blocking APIs.

Reviewed Changes

Copilot reviewed 32 out of 37 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
sdk/src/main/java/io/opentdf/platform/sdk/KASClient.javaUpdated KASClient constructor, stub retrieval, and close logic to use connect‑rpc.
sdk/src/main/java/io/opentdf/platform/sdk/Config.javaCleaned up redundant imports.
sdk/src/main/java/io/opentdf/platform/sdk/Autoconfigure.javaUpdated attribute grants retrieval to use blocking client APIs.
sdk/src/main/java/io/opentdf/platform/sdk/AddressNormalizer.javaAdded new address normalization logic using URI with updated scheme handling.
sdk/buf.yaml and sdk/buf.gen.yamlUpgraded buf version and reconfigured code generation plugins.
examples/…Updated examples to use new blocking methods and connect‑rpc ResponseMessageKt utilities.
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:252

  • [nitpick] The use of 'req' followed by 'request' in the same method can be confusing; consider using a consistent or more descriptive naming scheme to improve clarity.
var req = RewrapRequest.newBuilder()

sdk/src/main/java/io/opentdf/platform/sdk/KASClient.java:44

  • Changing KASClient visibility from public to package-private may limit external accessibility. Confirm if this change is intentional or consider reverting to public.
class KASClient implements SDK.KAS {

dmihalcik-virtru
dmihalcik-virtru previously approved these changes May 8, 2025
Comment threadsdk/src/main/java/io/opentdf/platform/sdk/SDKBuilder.java Outdated
Co-authored-by: Dave Mihalcik <dmihalcik@virtru.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate FailedQuality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@mkleene
mkleene merged commit ff36a1d into mainMay 9, 2025
@mkleene
mkleene deleted the feature/connect-rpc branch May 9, 2025 13:53
mkleene pushed a commit that referenced this pull request May 27, 2025
🤖 I have created a release *beep* *boop*
---
<details><summary>0.8.0</summary>
## [0.8.0](v0.7.9...v0.8.0)
(2025-05-27)
### ⚠ BREAKING CHANGES
* **sdk:** better control which classes we expose
([#254](#254))
* **sdk:** expose method to build an http client
([#256](#256))
* **sdk:** switch to `connect-rpc` for GRPC
([#244](#244))
* **sdk:** DSPX-1037 update sdk api
([#249](#249))
### Features
* Add initial Dependency Review configuration
([#252](#252))
([ba11d49](ba11d49))
* **sdk:** add nanotdf plaintext policy
([#259](#259))
([be9cd94](be9cd94))
* **sdk:** better control which classes we expose
([#254](#254))
([e00eeaf](e00eeaf))
* **sdk:** DSPX-1037 update sdk api
([#249](#249))
([f2e1307](f2e1307))
* **sdk:** expose method to build an http client
([#256](#256))
([2cac97c](2cac97c))
* **sdk:** switch to `connect-rpc` for GRPC
([#244](#244))
([ff36a1d](ff36a1d))
### Bug Fixes
* **sdk:** add coverage
([#258](#258))
([e6ad1bc](e6ad1bc))
</details>
---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Co-authored-by: opentdf-automation[bot] <149537512+opentdf-automation[bot]@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@mkleene@dmihalcik-virtru