Skip to content

Conversation

@blast-hardcheese
Copy link
Contributor

@blast-hardcheese blast-hardcheese commented Nov 6, 2024

Why

River Schema v2 compatibility so we can start getting rid of the compatibility layer.

What changed

Client

Significantly restructured the river.v2.*.

  • Nearly all asyncio.Lock's have been removed
  • Background tasks are now cleaned up correctly, which should reduce the amount of noise around tasks being GC'd while they're still running
  • Move websocket state ownership from Client transport down into Client Session. This significantly simplifies transparent reconnects, since we don't need to coordinate state shifting.
  • There are four background tasks:
    • Heartbeat checker. This keeps track of whether we've gotten any heartbeats from the server recently.
    • "Close session" checker. This keeps track of whether we've exceeded the grace period for transparent reconnects.
    • Buffered message sender. One downside with the previous implementation was that we had a race on sending messages over the websocket, since we had no coordination between calls to send_message when called concurrently, so we'd end up with seq bound and incremented but then messages would become out-of-order by the time the ws.send method returned. Now we just atomically append to a deque as we push onto the send buffer, and when we get a confirmation from the ws library we move the message over to an ack buffer (also a deque) waiting for incoming messages from the server to allow us to drain.

Codegen

  • init is now required for all method types, input is now optional. This simplifies rpc and stream codegen.
  • Fixed some bugs where init was being used in input position and vice versa.
  • Swapping f"'{foo}'" encoding for f"{repr(foo)}", giving greater safety post-generation (to avoid situations where f"'{None}'" gets rendered as "None". f"{repr(None)}" would render as None which would fail typechecks.)

Test plan

Manually ran codegen against v2 generated schemas, everything typechecks.

@blast-hardcheese blast-hardcheese requested a review from a team as a code owner November 6, 2024 06:40
@blast-hardcheese blast-hardcheese requested review from masad-frost and removed request for a team November 6, 2024 06:40
@blast-hardcheese blast-hardcheese added the enhancement New feature or request label Nov 6, 2024
@blast-hardcheese blast-hardcheese force-pushed the dstewart/feat/river-v2-codegen branch 2 times, most recently from a59a4df to dadffb8 Compare November 6, 2024 07:31
Copy link
Member

@masad-frost masad-frost left a comment

Choose a reason for hiding this comment

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

Do you wanna set up a different base branch in case we need to send a patch against main?

@blast-hardcheese blast-hardcheese force-pushed the dstewart/feat/river-v2-codegen branch from dadffb8 to 4c0e071 Compare November 6, 2024 21:03
@blast-hardcheese
Copy link
Contributor Author

Do you wanna set up a different base branch in case we need to send a patch against main?

If we need to patch, we should do feature patches off previous release tags. Since we're reserving 1.x for GA, I can follow the 0.200.0 strategy in this repo for schema-v2 releases.

Doing that though would suggest that we do at least a halfway decent pass at the v2 server codegen as well though. Given what we discussed supporting v1/v2 using a naive shim doesn't seem too bad, probably can get that done this week.

Wdyt?

@blast-hardcheese blast-hardcheese force-pushed the dstewart/feat/river-v2-codegen branch 2 times, most recently from b71a809 to 717cc68 Compare November 7, 2024 22:35
@blast-hardcheese blast-hardcheese force-pushed the dstewart/feat/river-v2-codegen branch 13 times, most recently from aa49136 to 747f7e1 Compare March 26, 2025 06:27
@blast-hardcheese blast-hardcheese force-pushed the dstewart/feat/river-v2-codegen branch from bb52361 to 7123e82 Compare April 8, 2025 02:34
@blast-hardcheese blast-hardcheese force-pushed the dstewart/feat/river-v2-codegen branch from 8589484 to ffc10ce Compare April 8, 2025 17:48
@blast-hardcheese blast-hardcheese force-pushed the dstewart/feat/river-v2-codegen branch from ffc10ce to 4820ef8 Compare April 8, 2025 20:56
@blast-hardcheese
Copy link
Contributor Author

Five remaining flakes in babel:

flaked:
- StreamDisconnectNotifs
- RpcDisconnectNotifs
- ShouldNotSendBufferAfterSessionDisconnect
- ComplexSituation
- UploadDisconnectNotifs

@blast-hardcheese blast-hardcheese added the minor Bump minor version label Apr 8, 2025
@blast-hardcheese blast-hardcheese merged commit ff13eeb into main Apr 8, 2025
3 checks passed
@blast-hardcheese blast-hardcheese deleted the dstewart/feat/river-v2-codegen branch April 8, 2025 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request minor Bump minor version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants