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

Change SSE to use the OkHttp public API only #8141

Merged
merged 2 commits into from
Dec 17, 2023
Merged

Conversation

swankjesse
Copy link
Collaborator

Previously we prevented end-users from using their own implementations of Call.Factory because we casted down to RealCall in RealEventSource.

With this change we're implementing SSE without depending on any OkHttp implementation details.

This also introduces a new function in EventSources to create an EventSource.Factory from a Call.Factory, and hides the previous implementation that required a concrete OkHttpClient.

Finally this fixes SSE to publish the same EventListener events as regular HTTP calls.

@swankjesse swankjesse requested a review from yschimke December 17, 2023 00:53
@swankjesse swankjesse force-pushed the jwilson.1216.okio370 branch 2 times, most recently from 384f648 to 0d23e7b Compare December 17, 2023 00:58
@swankjesse swankjesse force-pushed the jwilson.1216.realcall branch from 18074ca to 87ec2b3 Compare December 17, 2023 01:00
@@ -64,7 +58,7 @@ internal class RealEventSource(
}

// This is a long-lived response. Cancel full-call timeouts.
call?.timeoutEarlyExit()
call?.timeout()?.cancel()
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is much better

listener.assertEvent(null, null, "hey");
listener.assertClose();

assertThat(eventListener.recordedEventTypes()).containsExactly(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, this seems reasonable, if not particularly useful.

Base automatically changed from jwilson.1216.okio370 to master December 17, 2023 14:19
Previously we prevented end-users from using their own
implementations of Call.Factory because we casted down
to RealCall in RealEventSource.

With this change we're implementing SSE without depending
on any OkHttp implementation details.

This also introduces a new function in EventSources to
create an EventSource.Factory from a Call.Factory, and
hides the previous implementation that required a concrete
OkHttpClient.

Finally this fixes SSE to publish the same EventListener
events as regular HTTP calls.
@swankjesse swankjesse force-pushed the jwilson.1216.realcall branch from 87ec2b3 to 4d2c11c Compare December 17, 2023 14:20
@swankjesse swankjesse merged commit f131fae into master Dec 17, 2023
21 checks passed
@swankjesse swankjesse deleted the jwilson.1216.realcall branch December 17, 2023 14:40
Sign up for free to 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.

4 participants