proxy: swap tungstenite for a simpler impl (#7353)

## Problem

I wanted to do a deep dive of the tungstenite codebase.
tokio-tungstenite is incredibly convoluted... In my searching I found
[fastwebsockets by deno](https://github.com/denoland/fastwebsockets),
but it wasn't quite sufficient.

This also removes the default 16MB/64MB frame/message size limitation.
framed-websockets solves this by inserting continuation frames for
partially received messages, so the whole message does not need to be
entirely read into memory.

## Summary of changes

I took the fastwebsockets code as a starting off point and rewrote it to
be simpler, server-only, and be poll-based to support our Read/Write
wrappers.

I have replaced our tungstenite code with my framed-websockets fork.

<https://github.com/neondatabase/framed-websockets>
This commit is contained in:
Conrad Ludgate
2024-05-16 12:05:50 +01:00
committed by GitHub
parent 923cf91aa4
commit 790c05d675
6 changed files with 107 additions and 124 deletions

View File

@@ -135,7 +135,14 @@ async def test_websockets_pipelined(static_proxy: NeonProxy):
query_message = "SELECT 1".encode("utf-8") + b"\0"
length2 = (4 + len(query_message)).to_bytes(4, byteorder="big")
await websocket.send(
[length0, startup_message, b"p", length1, auth_message, b"Q", length2, query_message]
length0
+ startup_message
+ b"p"
+ length1
+ auth_message
+ b"Q"
+ length2
+ query_message
)
startup_response = await websocket.recv()