Skip to content

Implementation of the first layer of the SSE Implementation for the Generator to consume #7535

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

gupta11
Copy link

@gupta11 gupta11 commented Jun 16, 2025

Description

Fern SDKs support a variety of powerful features like auto-pagination, retries, and streaming. Java supports newline-delimited JSON streaming, but we haven't built out server-side event (SSE) streaming yet. This PR is the first step in enabling the generator to accept SSE on Java

Changes Made

  • Added secondary constructor to Stream.java that enables the use for SSE.
  • Implemented a parser for SSE
  • Added StreamOptions that are required for SSE stream type.

Testing

  • Unit tests added/updated
  • Manual testing completed

@gupta11 gupta11 self-assigned this Jun 16, 2025
@gupta11 gupta11 requested a review from amckinney June 16, 2025 19:33
streaming.visit(new GetStreamingResponseTerminator()).orElse("\n");
String prefix = ":data ";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prefix value ":data " doesn't match the DEFAULT_VALUE_PREFIX of "data: " defined in Stream.java. This inconsistency will cause SSE parsing to fail since the stream parser will be looking for lines starting with "data: " but the actual data will be prefixed with ":data ". Please update this value to "data: " to ensure consistent behavior with the default implementation.

Suggested change
String prefix = ":data ";
String prefix = "data: ";

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants