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

Question: how to implement sharding while keeping the API functionality #4

Open
ig4e opened this issue Feb 15, 2024 · 6 comments
Open
Labels
enhancement New feature or request

Comments

@ig4e
Copy link

ig4e commented Feb 15, 2024

how to implement sharding while keeping the API functionality, I tried getting the queue using useQueue from discord-player while sharding and sadly there's no data

@twlite
Copy link
Owner

twlite commented Feb 15, 2024

useQueue does work, @mariusbegby did it with cadence bot. Correct shard with correct guild id should work just fine when invoked from discord.

However the website may not work with shards using current setup, as any of the shard may receive the request. The overall design of this project does not involve sharding in mind but I will be happy to include this feature in the future.

@twlite twlite added the enhancement New feature or request label Feb 15, 2024
@mariusbegby
Copy link

@ig4e there should be no special considerations when using useQueue() and sharding. For example, look at this pause command and how useQueue() is implemented: https://github.com/mariusbegby/cadence-discord-bot/blob/main/src/interactions/slashcommands/pause.ts

It just takes guild id as normal.

@ig4e
Copy link
Author

ig4e commented Mar 2, 2024

@mariusbegby There are no special considerations on the bot side, but it currently doesn't manage/detect shards on the API side.

How will communication between different shards/processes with discord-player bindings be implemented?

@ig4e
Copy link
Author

ig4e commented Mar 2, 2024

useQueue does work, @mariusbegby did it with cadence bot. Correct shard with correct guild id should work just fine when invoked from discord.

However the website may not work with shards using current setup, as any of the shard may receive the request. The overall design of this project does not involve sharding in mind but I will be happy to include this feature in the future.

Thanks! I would love to see how it's done, I appreciate it if you could give me a hint ^^

@mariusbegby
Copy link

@ig4e I am not sure what problem you are running into. I am sharding using discord.js, nothing fancy and it works out of the box. I don't need a different setup of discord-player to get it to work with sharding. It works exactly the same as if no sharding would be used.

Hopefully you get something working, but I honestly cannot see what the problem is here.

@twlite
Copy link
Owner

twlite commented Mar 3, 2024

as far as I understand, @ig4e is talking about the website part, which I've already responded to saying

However the website may not work with shards using current setup, as any of the shard may receive the request. The overall design of this project does not involve sharding in mind but I will be happy to include this feature in the future.

The website part may not receive correct shard because there would also be multiple clusters of web servers working simultaneously meaning any of those would receive the request we send. This was not considered while implementing the api, due to which it is not possible to use the website with shards at the moment. We'll need to update the code to include data from all shards in the rest api part.

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

No branches or pull requests

3 participants