Skip to content
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

partyserver and friends #57

Merged
merged 1 commit into from
Jul 3, 2024
Merged

partyserver and friends #57

merged 1 commit into from
Jul 3, 2024

Conversation

threepointone
Copy link
Collaborator

This PR looks like a lot, but is actually quite straightforward, and removes more code than it adds. Happy to do a 1:1 walkthrough before it lands.

  • use nanoid for id generation. This lets us control the generated id lengths without sacrificing entropy, and avoids special characters like -.
  • use partysocket as a websocket replacement, that comes inbuilt with buffering, resilience, reconnection, etc
  • separates mode and env in AppLoadContext
  • avoid a roundtrip when generating a new room
  • rewrite the durable object with partyserver
    • enables hibernation
    • responds to pings without waking up the object
    • use the connection to store session data about the user
    • use an alarm to broadcast roomstate every 30 seconds

@threepointone threepointone force-pushed the partyserver branch 3 times, most recently from c498e92 to 46b948c Compare July 3, 2024 11:35
@threepointone
Copy link
Collaborator Author

one of the problems with this PR is that it loses state of tracks on reconnection. I'll fix this before landing.

@threepointone threepointone force-pushed the partyserver branch 2 times, most recently from ed523bb to ea7d4d8 Compare July 3, 2024 12:15
@danecando
Copy link

danecando commented Jul 3, 2024

I've been messing around building some stuff based around this repo and one of the things I spent some time on was using partykit instead of a plain durable object. I landed on and started to work on just pulling some code from partykit so I'm really excited to see that it looks like you're publishing a library that just provides the partykit server abstraction without the entire party. Is this something you plan on open sourcing soon? (I see you published an npm package for now)

Also - love partykit and the work you've done. Excited to see you contributing to this project!

Edit: The reason I decided not to just use partykit was that I'm building a workers project and I needed the servers to share development data (KV, etc). It didn't seem like it would be trivial to make that work correct me if I'm wrong about that

@threepointone
Copy link
Collaborator Author

Hi @danecando!

Yup, PartyServer will be open sourced soon, first testing it in production apps (like this one!). I'll also write up migration docs (hopefully painless/automated) and plans for the future. Like you, I'm building it so folks can use it in workers projects along with all their other bindings/resources.

- use `nanoid` for id generation. This lets us control the generated id lengths without sacrificing entropy, and avoids special characters like `-`.
- use `partysocket` as a websocket replacement, that comes inbuilt with buffering, resilience, reconnection, etc
- separates `mode` and `env` in `AppLoadContext`
- avoid a roundtrip when generating a new room
- rewrite the durable object with partyserver
  - enables hibernation
  - responds to pings without waking up the object
  - use the connection to store session data about the user
  - use an alarm to broadcast roomstate every 30 seconds
@threepointone threepointone merged commit af79f7b into main Jul 3, 2024
2 checks passed
@threepointone threepointone deleted the partyserver branch July 3, 2024 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants