Comments (7)
The standard way to handle this would be to have a channel per variable and subscribe each client to the channels of interest, and then use a channel manager to control access. Is there a reason this wouldn't work? Are there a lot of variables?
from django-eventstream.
I thought about this option, but the amount of variables depends on the use.
For my use cases, I can easily have more than 50 variables.
That's why I'm thinking of letting the server decide for a broadcast channel which client to send the information to.
from django-eventstream.
Hmm, yes 50 channels per connection would be quite a lot. Currently there is a limit of 10.
The main problem with lots of channels are amplification effects on other components, for example when using django-evenstream along with Pushpin chained to a message broker or something. However, if you are only using django-eventstream itself (as you would have to be for this validation function mechanism to work), then I think the effect would merely be a reasonable increase in memory usage within django-evenstream. In that case, 50+ channels per-connection is probably fine. Maybe even 1000 channels per-connection would be fine.
What do you think about simply making the limit configurable and using more channels?
from django-eventstream.
On the client side, there is no effect to keep open 50 or more channels ?
I think it is a better architecture approach to have a broadcast channel where all the devices can send new data and the web server is in charge of the message distribution.
Why don't you like my proposition of a validation function per client ?
from django-eventstream.
Client awareness of channels is optional. Normal use of django-eventstream is for the server to select the channels, e.g.:
urlpatterns = [
...
path('/events', include(django_eventstream.urls), {'channels': list_of_50_channels})
...
]
The main reason I suggest trying to use channels is it can scale better if you grow to multiple server nodes, but maybe that's not a concern.
I suppose the advantage of the broadcast channel is that it is more dynamic. You could grant a user access to an existing variable or start sending a new variable, and existing client connections could receive the data. Otherwise, clients would have to reconnect to get new channels assigned. I'm open to a PR to that lets the user provide a validation function (maybe call it a filter?). But it shouldn't go in sse_encode_event
as that's a serialization function.
from django-eventstream.
Should the filter go here and here ?
from django-eventstream.
seems reasonable
from django-eventstream.
Related Issues (20)
- What is the difference between evenstream and websockets? HOT 2
- Does not work for utf-8 symbols HOT 1
- Headers are missing in django-eventstream url patterns HOT 1
- Support for django-rq HOT 1
- ModuleNotFoundError: No module named 'channels.http' HOT 3
- CORS Error: How can we allow multiple origins HOT 2
- Compatibility with htmx HOT 5
- How to run examples using Uvicorn? HOT 4
- AttributeError: 'ASGIRequest' object has no attribute 'grip' HOT 1
- Django rest framework router register eventstream HOT 2
- Further pull request for REST version
- Change path of static file
- Question: Why Django 5+? HOT 1
- Improve logging HOT 1
- Interested in tests dev ? HOT 2
- IMPORTANT !! - Publish problem HOT 5
- How to use event stream trough multiple worker HOT 25
- drf support not up to date HOT 4
- RedisStorage seems to be broken HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-eventstream.