-
Notifications
You must be signed in to change notification settings - Fork 653
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
Introduce incubating WebSocketEngine #5676
Conversation
✅ Deploy Preview for apollo-android-docs canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good 👍
/** | ||
* Creates a new [WebSocket]. | ||
* | ||
* The [WebSocket] is be garbage collected when not used anymore. Call [WebSocket.close] to close the websocket and release resources earlier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* The [WebSocket] is be garbage collected when not used anymore. Call [WebSocket.close] to close the websocket and release resources earlier. | |
* The [WebSocket] will be garbage collected when not used anymore. Call [WebSocket.close] to close the websocket and release resources earlier. |
Actually maybe the 1st sentence can be removed? As it's true of any type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm on a crusade to remove future tense from our docs. It's what our style guide says (internal link) and I tend to agree despite being guilty of a lot of the current usage.
I'll remove the extra 'be' but I'm in favor of keeping the sentence. IO streams like InputStream
usually need closing because they hold file descriptors or other resources. Here the file descriptor is released automatically on websocket error or server close. It might become the norm at some point but I don't think we're there yet.
val d = JSON.stringify(data2) | ||
if (!disposed) { | ||
disposed = true | ||
listener.onError(DefaultApolloException("The JS WebSocket implementation only support text messages (got $d)")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the Buffer.isBuffer(data2)
case for data messages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I'll update the message
|
||
import okhttp3.OkHttpClient | ||
|
||
internal val defaultOkHttpClientBuilder: OkHttpClient.Builder by lazy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just calling OkHttpClient.Builder()
on demand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to share the OkHttp threadpool between WebSockets and HTTP. So this is technically not used right now but I'll enable it when swapping the websocket network transport is not incubating anymore.
The incubating WebSocketEngine uses events instead of coroutines, making it easier to map to the underlying implementations (OkHttp, NSUrlSession and JS WebSocket are all event-based).
It also fixes a memory leak in the Apple WebSocketEngine (the NSUrlSession wasn't cancelled).
This PR also makes wasm tests "work" again. They are mostly ignored but you can now type
./gradlew build
and the build will pass. They were failing previously because trying to run on a node version that did not support wasm.