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

Allow sending messages in bulk #399

Open
olzhasar opened this issue Sep 14, 2024 · 2 comments
Open

Allow sending messages in bulk #399

olzhasar opened this issue Sep 14, 2024 · 2 comments

Comments

@olzhasar
Copy link

Feature request

Sometimes there is a need to send multiple messages to a channel (or group) at once. While this can be done using a group of asyncio tasks, the underlying logic will be suboptimal, cause there would be multiple redis calls for discarding old messages, checking the capacity, appending to the set and setting the expiration.

It would be cool if there were optimized functions for that using a single zadd call.
Something like this:

    async def send_multiple(self, channel, messages: list):
        ...

    async def group_send_multiple(self, channel, messages: list):
        ...

I am not sure if such an issue should be created in the channels repo first, let me know if that's the case.

@carltongibson
Copy link
Member

This isn't a bad idea. We'd probably need to add something to the base channel layer, and docs too.

Do you want to experiment with an implementation?

@olzhasar
Copy link
Author

Sure, I will prepare a PR for this once I have some free time.

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

No branches or pull requests

2 participants