public static class DefaultShardingStrategy.Builder extends Object
ShardingStrategy
builder.Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
ShardingStrategy |
build()
Create the
ShardingStrategy . |
DefaultShardingStrategy.Builder |
count(int shardCount)
Set the shard count parameter.
|
DefaultShardingStrategy.Builder |
filter(Predicate<ShardInfo> shardFilter)
Set a filter to determine which shards should be accepted for identifying to Discord Gateway.
|
DefaultShardingStrategy.Builder |
indices(Function<Integer,Publisher<Integer>> shardIndexSource)
Set a generator function to derive a
Publisher of shard indices to identify to Discord Gateway. |
DefaultShardingStrategy.Builder |
indices(int... shardIndices)
Set the list of shard indices to identify to Discord Gateway.
|
DefaultShardingStrategy.Builder |
maxConcurrency(int maxConcurrency)
Set the sharding maximum concurrency to use when identifying to the Discord Gateway, determining the
amount of shards that will be concurrently identified.
|
public DefaultShardingStrategy.Builder count(int shardCount)
RECOMMENDED_SHARD_COUNT
. Must not be negative.shardCount
- the shard count sent to Discord while identifying each GatewayClient
public DefaultShardingStrategy.Builder indices(int... shardIndices)
indices(Function)
.shardIndices
- the list of shard indices to identifypublic DefaultShardingStrategy.Builder indices(Function<Integer,Publisher<Integer>> shardIndexSource)
Publisher
of shard indices to identify to Discord Gateway.
Defaults to identify all shards. Any invocation of this method will also replace the previously set value
at indices(int...)
.shardIndexSource
- the generator function to determine the shards to identifypublic DefaultShardingStrategy.Builder filter(Predicate<ShardInfo> shardFilter)
shardFilter
- a Predicate
for ShardInfo
objects. Called for each shard determined by
count(int)
and schedules it for connection if returning true
.public DefaultShardingStrategy.Builder maxConcurrency(int maxConcurrency)
maxConcurrency
always needs to be a power of 2 and must not be lower than one.maxConcurrency
- a positive number indicating the amount of shards that can be identified concurrently.public ShardingStrategy build()
ShardingStrategy
.ShardingStrategy