feat(java-sdk): use common streaming utils, reverse sync streaming API layer
Description
generates https://github.com/openfga/java-sdk/pull/261
What problem is being solved?
How is it being solved?
What changes are made to solve it?
References
Review Checklist
- [ ] I have clicked on "allow edits by maintainers".
- [ ] I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
- [ ] The correct base branch is being used, if not
main - [ ] I have added tests to validate that the change in functionality is working as expected
[!IMPORTANT]
Review skipped
Auto incremental reviews are disabled on this repository.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
[!NOTE]
Other AI code review bot(s) detected
CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.
Walkthrough
This PR adds Java streaming API support by introducing template files for streaming response handling. Three new classes are defined: StreamResult<T> (generic wrapper), BaseStreamingApi (abstract base for streaming), and StreamedListObjectsApi (concrete implementation). Configuration overrides are added to map these templates to their target Java source locations.
Changes
| Cohort / File(s) | Summary |
|---|---|
Configuration mappingconfig/clients/java/config.overrides.json |
Adds four new mustache-to-destination mappings for streaming API templates: StreamResult.mustache, BaseStreamingApi.mustache, and StreamedListObjectsApi.mustache, all categorized as SupportingFiles. |
Streaming response wrapperconfig/clients/java/template/libraries/native/StreamResult.mustache |
Introduces generic StreamResult<T> class with fluent setters, Jackson annotations, and standard object overrides. Models line-by-line deserialized streaming responses containing either a result of type T or an error of type Status. |
Base streaming handlerconfig/clients/java/template/libraries/native/BaseStreamingApi.mustache |
Defines abstract BaseStreamingApi<T> class with centralized HTTP streaming logic via processStreamingResponse(), line-level parsing in processLine(), robust error handling with optional errorConsumer, and HTTP request construction via buildHttpRequest(). |
Streamed API endpointconfig/clients/java/template/libraries/native/StreamedListObjectsApi.mustache |
Introduces StreamedListObjectsApi extending BaseStreamingApi<StreamedListObjectsResponse> with four overloaded streamedListObjects() methods supporting optional configuration overrides and error callbacks. Validates required parameters and constructs streaming HTTP POST requests. |
Sequence Diagram(s)
sequenceDiagram
participant Client
participant StreamedListObjectsApi
participant BaseStreamingApi
participant HttpClient
participant Consumer
Client->>StreamedListObjectsApi: streamedListObjects(storeId, body, consumer)
StreamedListObjectsApi->>StreamedListObjectsApi: validateParameters()
StreamedListObjectsApi->>StreamedListObjectsApi: buildHttpRequest(POST, path, body)
StreamedListObjectsApi->>BaseStreamingApi: processStreamingResponse(request, consumer, errorConsumer)
BaseStreamingApi->>HttpClient: send(httpRequest)
HttpClient-->>BaseStreamingApi: response stream
loop For each line
BaseStreamingApi->>BaseStreamingApi: processLine(line)
BaseStreamingApi->>BaseStreamingApi: deserialize to StreamResult<T>
alt Error in StreamResult
BaseStreamingApi->>BaseStreamingApi: invoke errorConsumer(error)
else Success
BaseStreamingApi->>Consumer: accept(result)
end
end
BaseStreamingApi-->>Client: CompletableFuture<Void>
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
- BaseStreamingApi: Extra attention needed for streaming logic correctness, error handling patterns (CompletionException unwrapping), and async consumer delivery semantics
- StreamedListObjectsApi: Verify multiple method overloads are correct and parameter validation is comprehensive
- Configuration mappings: Confirm template destination paths and file categorization are accurate
Possibly related PRs
- openfga/sdk-generator#656: Switches the Makefile to the streamed build target that produces the streaming client code generated by these new template definitions.
Suggested reviewers
- ewanharris
- rhamzeh
Pre-merge checks and finishing touches
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title accurately describes the main changes: introducing common streaming utilities and a reverse sync streaming API layer for the Java SDK, which matches the new BaseStreamingApi, StreamResult, and StreamedListObjectsApi classes. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.