Repository navigation
feat(net): scope origin announcement interest #4234
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
Merged
+543
−138
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e20b13d
chore(quest): claim js-origin-scope
kixelated 0a7fb9b
Merge remote-tracking branch 'origin/main' into quest/m1/js-origin-scope
kixelated d06fd5e
feat(net): scope origin announcement interest
kixelated c7b49df
Merge remote-tracking branch 'origin/main' into merge-4234
kixelated 0f61bda
fix(net): filter scoped routes by their origin scope and prefer the m…
kixelated 7609212
Merge remote-tracking branch 'origin/main' into merge-4234
kixelated File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { expect, test } from "bun:test"; | ||
| import * as Ietf from "../ietf/index.ts"; | ||
| import * as Lite from "../lite/index.ts"; | ||
| import { createMockTransportPair } from "../mock.ts"; | ||
| import { Producer } from "../origin.ts"; | ||
| import * as Path from "../path.ts"; | ||
| import { withTimeout } from "../util/timeout.ts"; | ||
| import { accept } from "./accept.ts"; | ||
| import { connect } from "./connect.ts"; | ||
|
|
||
| for (const protocol of [Lite.ALPN_07_WIP, Ietf.ALPN.DRAFT_19]) { | ||
| test(`scoped origins discover multiple prefixes over ${protocol}`, async () => { | ||
| const pair = createMockTransportPair(protocol); | ||
| const url = new URL("https://localhost/test"); | ||
| const source = new Producer(); | ||
| const destination = new Producer(); | ||
| const publish = source.scope(Path.from("server"), new Path.Patterns([Path.Pattern.all()])); | ||
| const consume = destination.scope( | ||
| Path.from("client"), | ||
| new Path.Patterns(["room/**", "other/**"].map(Path.Pattern.parse)), | ||
| ); | ||
| const broadcasts = ["room/live", "room/.hidden", "other/live", "outside"].map((path) => { | ||
| const broadcast = publish.createBroadcast(Path.from(path)); | ||
| broadcast.announce(); | ||
| return broadcast; | ||
| }); | ||
| const [client, server] = await Promise.all([ | ||
| connect({ url, transport: pair.client, consume }), | ||
| accept({ url, transport: pair.server, publish: publish.consume() }), | ||
| ]); | ||
| const announced = destination.announced(undefined, { hidden: true }); | ||
| try { | ||
| const received: string[] = []; | ||
| for (let index = 0; index < 3; index++) { | ||
| const update = await withTimeout(announced.next(), 1000, "scoped announcement did not arrive"); | ||
| if (!update) throw new Error("announcement stream ended before replay"); | ||
| expect(update.kind).toBe("announced"); | ||
| received.push(update.prefix); | ||
| } | ||
| expect(received.sort()).toEqual(["client/other/live", "client/room/.hidden", "client/room/live"]); | ||
| expect([...consume.broadcasts().peek().keys()].sort()).toEqual([ | ||
| Path.from("other/live"), | ||
| Path.from("room/live"), | ||
| ]); | ||
| } finally { | ||
| announced.close(); | ||
| client.close(); | ||
| server.close(); | ||
| for (const broadcast of broadcasts) broadcast.close(); | ||
| source.close(); | ||
| destination.close(); | ||
| await Promise.all([client.closed, server.closed]); | ||
| } | ||
| }); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With multiple disjoint heads and a peer advertising a prefix above them, such as
""fora/**andb/**, everyconn.announcedstream emits the same advertisement, but this per-stream map creates a separateDynamicanddrivetask for each copy. The IETF subscriber explicitly sends one broad advertisement to every matching consumer in#attachAnnounce, so route storage and repricing work grow with heads times routes; if one stream ends, closing the selected duplicate can also rematerialize active requests through an identical entry. Share or reference-count received prefixes across these streams, and benchmark interest heads against routes. (Written by GPT-5.6 Sol)AGENTS.md reference: AGENTS.md:L35-L35
Useful? React with 👍 / 👎.