Conversation
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
Deploying h3-crossws with
|
| Latest commit: |
023ea1b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://cd0588b6.h3-crossws.pages.dev |
| Branch Preview URL: | https://feat-isolate-pubsub.h3-crossws.pages.dev |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In the current version of crossws, there is one
peersglobal set per server. Publishing to the same "topic", published to all peers of the same topic.While it works in simple servers with a single set of hooks, when using dynamic hooks (using resolver), it makes sense that each peer only subscribe and publish to relevant peers and topics don't overlap.
This PR segments global peers into "namespaces". By default, the request "pathname" is used for namespace, so peers connected to
/_ws/room1and/_ws/room2are isolated from each other (BREAKING CHANGE).It is possible to have customized namespace logic based on request:
getNamespace: (req: Request) => string)upgrade(req)hook by returning{ namespace }Global
.publish(topic, message)still publishes to all peers, but can specify a namespace using.publish(topic, message, { namespace })