Add RSocket support, again #297
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On Apple platforms,
NSURLSessionis used to implement the HTTP client. That API does not support backpressure or pausing / resuming streamed HTTP responses (there are thesuspend()andresume()method on download tasks, but these don't work).As a fallback to avoid overloading slow clients, this brings back RSocket support over WebSockets. RSocket doesn't have this issue because clients explicitly request more frames that a server is allowed to send.
I see the fact that RSocket is used as an implementation detail, so there's no public API to enable or disable WebSockets. Instead, packages depending on the Darwin client implementation register a hook informing
:commonthat backpressure is unsupported. When setting up the HTTP client, we then register WebSocket support and patch the frame size to ensure we can receive large messages.For the websocket implementation, this essentially reverts #232.
I have tested that the JVM client continues to use regular HTTP. I've also tested the example multiplatform app in an iOS simulator to verify that websockets are used. Finally, I've synced a large row (inserted a Postgres value as
repeat('A', 10485760)to create a 10MiB row) to verify that RSocket framing / custom max websocket frame sizes for Darwin works (which required updating ktor to the latest version).