Skip to content

refactor: Route stream key resolution to one loop - #86

Merged
kimsun721 merged 2 commits into
mainfrom
refactor/85-route-stream-key
Oct 14, 2026
Merged

kimsun721 merged 2 commits into
mainfrom
refactor/85-route-stream-key

Conversation

@kimsun721

Copy link
Copy Markdown
Owner

Route stream key resolution to one loop

Why

A stream key carried no loop, so resolving one asked every loop. It was the only HTTP request that fanned out: its reply needed an mpsc, it answered 503 if any loop was full, and one wrong key cost a message on every loop.

Changes

  • A stream key is SK_<loop>_<random>, like a room id. The loop comes from the room id when the key is issued or reissued.
  • Shards::sender_by_key reads the loop from either kind of id, replacing sender_for.
  • Resolution asks that loop alone and awaits a oneshot reply.
  • A key without a loop number, or with one past the last loop, gets 401 without a loop being asked.
  • A loop that drops the reply now gives 500, not 401.
  • ADR 0013 records the key format and supersedes the stream key resolution in ADR 0012. The architecture overview follows.

Tested

  • cargo test: all suites pass.
  • New test: a wrong key gets 401 whether its loop exists or not. The client has a timeout, so a request left waiting fails the test.

Closes #85

@kimsun721
kimsun721 merged commit 08714ca into main Oct 14, 2026
1 check passed
@kimsun721
kimsun721 deleted the refactor/85-route-stream-key branch October 14, 2026 18:36
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.

[REFACTOR] Route stream key resolution to one loop

1 participant