8000 refactor: restructure websocket implementation by augustoccesar · Pull Request #235 · mentimeter/linkup · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

refactor: restructure websocket implementation #235

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 8000 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

Merged
merged 12 commits into from
May 13, 2025

Conversation

augustoccesar
Copy link
Collaborator
@augustoccesar augustoccesar commented Apr 24, 2025

Use tungstenite for handling websocket on local-server.
With this implementation we should have a more stable handling of the events and specially of the closing.

@augustoccesar augustoccesar self-assigned this Apr 24, 2025
Base automatically changed from next to main May 5, 2025 07:28
@augustoccesar augustoccesar marked this pull request as ready for review May 6, 2025 13:04
@augustoccesar augustoccesar requested a review from ostenbom May 6, 2025 13:04
@augustoccesar augustoccesar changed the base branch from main to next May 7, 2025 07:02
// TODO: Handle both connection errors here and failed responses.
let (ws_stream, upstream_response) = tokio_tungstenite::connect_async(request)
.await
.expect("WebSocket connection failed");
Copy link
Contributor

Choose a reason for hiding this comment

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

Match on error:

  • If it's Err(HttpResponse) - there is a valid http response even though the websocket didn't connect, return the response to the client (such as 404)
  • for other errors - Return a real error / 503 ish

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed on 0f0e525. Were you thinking of something like that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Super - love it

Comment on lines 231 to 232
Some(upgrade) => {
let mut url = target_service.url;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can fix the naming here a bit to match the upstream/downstream terminology? I had a hard time spotting the ws_stream & upgrade distinction after not looking at the code for a while

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you mean the naming of url or the upgrade? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Mostly the upgrade which becomes - upgrade.on_upgrade(ws::context_handle_socket(ws_stream)); - is upgrade the upstream/downstream and is ws_stream the upstream/downstream

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe something like this? e4a33aa

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

And maybe with this f4c4c03 (now I'm confused as well 😅 )

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's right! "the next hop along" is upstream

@augustoccesar augustoccesar requested review from ostenbom and a team and removed request for ostenbom May 12, 2025 08:35
@augustoccesar augustoccesar requested a review from ostenbom May 13, 2025 12:20
@augustoccesar augustoccesar merged commit e70fdfe into next May 13, 2025
6 checks passed
@augustoccesar augustoccesar deleted the augustoccesar/refactor-ws-implementation-on-local branch May 13, 2025 12:21
augustoccesar added a commit that referenced this pull request Jun 5, 2025
Changes:
- #235 
- fix: update documentation link on --help (affc913)
- #240 (ty @ostenbom )

---------

Co-authored-by: Oliver Stenbom <oliver@stenbom.eu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0