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

Shardmanager - Dynamic shard startup #1757

Open
3 tasks done
Horstexplorer opened this issue Aug 2, 2021 · 0 comments
Open
3 tasks done

Shardmanager - Dynamic shard startup #1757

Horstexplorer opened this issue Aug 2, 2021 · 0 comments

Comments

@Horstexplorer
Copy link
Contributor

Horstexplorer commented Aug 2, 2021

General Troubleshooting

  • I have checked for similar issues.
  • I have updated to the [latest JDA version][download].
  • I have checked the branches or the maintainers' PRs for upcoming features.

Feature Request

Adjust the Shardmanager to allow for dynamic clustering without fancy workarounds

Example Use-Case

Feature request originating from chat in #1721

It would be great to allow building the Shardmanager without defining the actual shards it will run later so we can dynamically let those match our needs when we think it is safe to do so.

Current Behaviour

A) We dont define any shards
var sm = DefaultShardManagerBuilder
	.createLight("TOUCAN")
	.setShardsTotal(totalshards) // lets say its 5
	.build(false);

When calling sm.start() the Shardmanager will proceed to start all shards from 0 to 4 in order. When calling start(int) with a shardid the same behaviour can be observed ignoring our selection.

B) We define some shards
var sm = DefaultShardManagerBuilder
	.createLight("TOUCAN")
	.setShardsTotal(totalshards) // lets say its 5
	.setShards(shards) // 0, 2, 3
	.build(false);

When calling sm.start() the Shardmanager will proceed to start all shards specified in order. When calling start(int) with a shardid the same behaviour can be observed ignoring our selection.

Expected Behaviour

A) We dont define any shards

No shards will be started when calling sm.start() which will require an explicit definition to use the auto sharding feature. Alternatively the current behaviour of starting all shards might remain tho this might feel a bit inconsistent then. Only the shard specified will be started when calling sm.start(int).

B) We define some shards

No shards will be started when calling sm.start() which will require an explicit definition to use the auto sharding feature. Alternatively the current behaviour of starting all defined shards might remain tho this might feel a bit inconsistent then. Only the shard specified will be started when calling sm.start(int).

Current Workaround

Define only the lowest shardid you would intend to start within the builder. When the shards are supposed to login, beginn calling start(int) starting with the lowest id. It is important that the specified id is the lowest and the same in both cases. As the shardmanager will ignore the id for the initial start, we might start the wrong shard without any simple ways to knowing this. Also this allows for easy sorting which makes it a bit less prone to breaking.

var sm = DefaultShardManagerBuilder
	.createLight("TOUCAN")
	.setShardsTotal(totalshards) // lets say its 5
	.setShards(0) // 0, (2, 3)
	.build(false);
...
sm.start(0)
sm.start(2)
sm.start(3)
@Horstexplorer Horstexplorer changed the title Shardmanager - Dynaming shard startup Shardmanager - Dynaminc shard startup Aug 2, 2021
@Horstexplorer Horstexplorer changed the title Shardmanager - Dynaminc shard startup Shardmanager - Dynamic shard startup Aug 2, 2021
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

1 participant