Package discord4j.core.shard
Class DefaultShardingStrategy
- java.lang.Object
-
- discord4j.core.shard.DefaultShardingStrategy
-
- All Implemented Interfaces:
ShardingStrategy
public class DefaultShardingStrategy extends Object implements ShardingStrategy
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDefaultShardingStrategy.BuilderAShardingStrategybuilder.
-
Field Summary
Fields Modifier and Type Field Description static intRECOMMENDED_SHARD_COUNTValue representing the use of a recommended amount of shards.
-
Constructor Summary
Constructors Constructor Description DefaultShardingStrategy(DefaultShardingStrategy.Builder builder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description discord4j.core.shard.GatewayClientGroupManagergetGroupManager(int count)Return theGatewayClientGroupManagerto maintain each gateway client in the created group.intgetMaxConcurrency()Return the number of shards that can be identified concurrently.Mono<Integer>getShardCount(RestClient restClient)Return the shard count used to create a group of sharded clients.Flux<ShardInfo>getShards(int shardCount)Return the shard factory used to create a group of sharded clients.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface discord4j.core.shard.ShardingStrategy
getMaxConcurrency
-
-
-
-
Constructor Detail
-
DefaultShardingStrategy
public DefaultShardingStrategy(DefaultShardingStrategy.Builder builder)
-
-
Method Detail
-
getShardCount
public Mono<Integer> getShardCount(RestClient restClient)
Description copied from interface:ShardingStrategyReturn the shard count used to create a group of sharded clients.- Specified by:
getShardCountin interfaceShardingStrategy- Parameters:
restClient- a handle to consume REST API resources, typically to retrieve the number of recommended shards- Returns:
- a shard count as a
Monoto obtain this number asynchronously.
-
getShards
public Flux<ShardInfo> getShards(int shardCount)
Description copied from interface:ShardingStrategyReturn the shard factory used to create a group of sharded clients.- Specified by:
getShardsin interfaceShardingStrategy- Parameters:
shardCount- the total number of shards- Returns:
- a shard factory as a sequence of
ShardInfoitems.
-
getGroupManager
public discord4j.core.shard.GatewayClientGroupManager getGroupManager(int count)
Description copied from interface:ShardingStrategyReturn theGatewayClientGroupManagerto maintain each gateway client in the created group.- Specified by:
getGroupManagerin interfaceShardingStrategy- Parameters:
count- the total number of shards- Returns:
- a
GatewayClientGroupManagerused by this strategy
-
getMaxConcurrency
public int getMaxConcurrency()
Description copied from interface:ShardingStrategyReturn the number of shards that can be identified concurrently. Must be 1 unless your application is authorized to use the large bot sharding system.- Specified by:
getMaxConcurrencyin interfaceShardingStrategy- Returns:
- a value determining the sharding factor this strategy has
- See Also:
- Sharding for very large bots
-
-