-
Notifications
You must be signed in to change notification settings - Fork 196
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
Sending Single Message Per Client Prefix/ User Prefix #107
Conversation
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.
I'm still not entirely clear what this is doing - the code is quite hard to read. Could you add some comments and make it very clear what's happening?
channels_redis/core.py
Outdated
redis.call('EXPIRE', KEYS[i], %d) | ||
end | ||
end | ||
""" % self.expiry |
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.
Why did you indent this without changing it?
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.
i guess the IDE did it. i will revert it.
channels_redis/core.py
Outdated
channel_key_to_message[key]["__asgi_channel__"] = ",".join(channel_key_to_message[key]["__asgi_channel__"]) | ||
channel_key_to_message[key] = self.serialize(channel_key_to_message[key]) | ||
|
||
return channel_keys, connection_to_channel_keys, channel_key_to_message, channel_key_to_capacity |
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.
This block needs some serious comments to say what's happening - I'm finding it hard to read.
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.
on it
(Correct me if i am understanding this wrong) originally when i called group_send('Group-A', message_dictionary) Modifications: On the receiving end i just process the message for all of the channels that are received in the message in a for loop. This Largely reduces the time to push group messages onto channel redis layer and the number of pops. |
46aa17e
to
d816512
Compare
channels_redis/core.py
Outdated
|
||
# channel_keys does not contain a single redis key more than once | ||
async with self.connection(connection_index) as connection: | ||
await connection.eval(group_send_lua, keys=channel_redis_keys, args=args) |
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.
previously channel_redis_keys would contain duplicate keys as multiple channels may map to same redis key. hence the more number of pushes.
OK, I mostly understand it now, but a couple of things I'd like to see changed:
|
|
Thanks! |
@andrewgodwin Thank you so much. This was my first PR to get merged . Yayy. :D |
previously for each channel subscribed to a group message was being pushed to list stored at channel key. I have grouped those messages by sending list of channels associated with that that channel redis key with a single message . It saves a great deal of time by reducing the number of push and pops from redis.
Fixes : #7, #83