-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
breaking: update tokio-tungstenite to 0.26 and update examples #3078
Conversation
42bdf98
to
23f96a3
Compare
The CI checks are failing. Can you check? |
given that we have our own downstream also, will clean up the commits in a bit |
Yes, we don't want to have tungstenite as a public dep. However I'm a bit undecided about what to expose exactly - I'll comment later after work. Also cc @SabrinaJewson |
So, my intial observation is that Tungstenite’s
To me, neither of these advantage seem worth it to add a whole new |
Those were pretty much my thoughts looking at the tungstenite change too 😅 So let's switch to |
The payload variants do have reasons to exist. For example, removing |
@@ -75,7 +75,7 @@ async fn ws_handler( | |||
res = ws.recv() => { | |||
match res { | |||
Some(Ok(ws::Message::Text(s))) => { | |||
let _ = sender.send(s); | |||
let _ = sender.send(s.to_string()); |
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.
This use case could show the shared bytes reuse.
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.
This could probably be left as a follow up task, if so maybe just add a TODO here?
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.
An issue usually works better than a fixme comment for stuff like this. Feel free to open one.
Do you know why that’s the case? Is it really just the memcpy due to having excess capacity in the Looking at the implementation of The reason I’m somewhat against a |
I do agree, I think payload started as |
It looks like the perf issues can be resolved. If possible please review that upstream PR and suggest changes so we can get the next breaking tungstenite version as right as possible. |
alright, will update this PR as soon as i get home with the newly released version. what to do about |
I just checked, looks like I was wrong. I think we can just newtype tungstenite's type then. |
cf67e9f
to
67c2ffc
Compare
Co-Authored-By: Alex Butler <[email protected]>
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.
There's a few things I'd like to look at and possibly improve before releasing, but this is definitely a big step in the right direction so I'll merge 👍
Self::Binary(ref data) | Self::Ping(ref data) | Self::Pong(ref data) => { | ||
Ok(std::str::from_utf8(data).map_err(Error::new)?) | ||
} | ||
Self::Close(None) => Ok(""), | ||
Self::Close(Some(ref frame)) => Ok(&frame.reason), | ||
} | ||
} | ||
|
||
/// Create a new text WebSocket message from a stringable. |
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.
Not sure how to word this, but "stringable" is not a word in my vocabulary :D
impl<T> PartialEq<T> for Utf8Bytes | ||
where | ||
for<'a> &'a str: PartialEq<T>, |
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.
Note to self: revisit.
Motivation
tokio-tungstenite had a new (breaking) release, 0.25/0.26 that finally allows sending shared data over websockets, and it would be cool if this new breaking change could get in axum 0.8.0 given it's a new major release
Solution
the websocket extract has been changed, and it now exposes
Bytes
andUtf8Bytes
(UTF-8 wrapper aroundBytes
)