-
Notifications
You must be signed in to change notification settings - Fork 80
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
Remove websocket
dependency and replace it with async bridging code to tokio-tungstenite
#146
Conversation
This introduces tokio and tokio_tungstenite as a dependency. The asynchronous socket supports the same interface as the normal socket with just async methods. The only way to execute it is with the tokio runtime.
This commit removes the Websocket dependency completly. Apparently the library was not maintained anymore and introduced an old hyper version with a security vulnerability. The new version uses async bridging with tokio in order to execute the futures produced by the async client.
2304006
to
e73c9e4
Compare
Force pushed due to commit rewording. |
Codecov Report
@@ Coverage Diff @@
## main #146 +/- ##
==========================================
+ Coverage 87.83% 88.26% +0.43%
==========================================
Files 20 24 +4
Lines 1644 1662 +18
==========================================
+ Hits 1444 1467 +23
+ Misses 200 195 -5
Continue to review full report at Codecov.
|
c149094
to
9a57f7d
Compare
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.
nit: force-pushing makes it harder to see what changed.
Thanks a lot for the review @nshaaban-cPacket! |
This PR replaces the current websocket code that uses the unmaintained
websocket
crate withtokio-tungstenite
.tokio-tungstenite
is async, so in order to get the current code to work I needed to use async-bridging. The idea is that the current websocket transport types hold atokio::Runtime
object where they spawn the futures with and then communicate the results like before.This fixes #115 and does the work of pr #123.
The changes introduce tokio as an async runtime. The current version of the async clients are bound to tokio and it is apparently quite hard to not choose an async runtime, as the underlying connection with the server is currently opened by this crate and thus needs some sort of type (either tokio or async-std streams).