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

Dynamic namespace support #1166

Closed
pobk opened this issue Apr 2, 2023 · 2 comments
Closed

Dynamic namespace support #1166

pobk opened this issue Apr 2, 2023 · 2 comments
Assignees

Comments

@pobk
Copy link

pobk commented Apr 2, 2023

Is your feature request related to a problem? Please describe.
I am unable to instantiate a server that is capable of accepting connections to dynamically assigned namespaces however the Socket.IO JS implementation supports Dynamic namespaces on the server through the use of th io.of(/^\/dynamic-\d+$/) construct. The specific use-case I have is related to a real-time case management platform in which many organisations participate, yet need to be held as secure and separate enclaves and silos. Each organisation uses, on average, 4-10 queues to process information. On top of this each open case establishes a SocketIO room to group updates to cases for subscribed parties.

On average, the platform has ~600 rooms active.

Describe the solution you'd like
This is probably best implemented as part of the Namespace classes instead of trying to bend heads around the non-class based implementations.

Ideally, at a minimum, the Namespace class could provide a regex property which could be validated against the incoming packets. However, the perfect option would be to utilise a callable on the namespace instance that provides a true/false response as to whether it elects to participate in processing the packet received.

Describe alternatives you've considered
I have been using rooms to separate these silos, however, the code to manage all the rooms, connections and routing is extremely complex. It structurally means I have to validate every request for authorisation to join, leave and send to every room.

A separate namespace would mean a vast reduction in the number of checks to perform. Furthermore it would simplify my architecture considerably as the namespace only needs to query the database for it's specific organisational records.

@miguelgrinberg
Copy link
Owner

This is probably best implemented as part of the Namespace classes instead of trying to bend heads around the non-class based implementations.

This isn't a definitive no, but I would prefer that whatever implementation is made for dynamic namespaces it covers both decorated and class-based usages. It should also handle both the sync and async servers or else I won't accept it.

However, the perfect option would be to utilise a callable on the namespace instance that provides a true/false response

That could work, and maybe the same idea could be applied to decorated handlers.

A separate namespace would mean a vast reduction in the number of checks to perform.

I disagree. It would reduce the checks that you do on your application, but those checks will not just disappear, they will be moved into this package. If that causes the server to slow down for everybody, then it wouldn't be a great solution. The vast majority of my users do not care about namespaces, they just use the default one.

@miguelgrinberg
Copy link
Owner

Implemented in #1288

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants