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 class
DefaultShardingStrategy.Builder
AShardingStrategy
builder.
-
Field Summary
Fields Modifier and Type Field Description static int
RECOMMENDED_SHARD_COUNT
Value 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.GatewayClientGroupManager
getGroupManager(int count)
Return theGatewayClientGroupManager
to maintain each gateway client in the created group.int
getMaxConcurrency()
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:ShardingStrategy
Return the shard count used to create a group of sharded clients.- Specified by:
getShardCount
in interfaceShardingStrategy
- Parameters:
restClient
- a handle to consume REST API resources, typically to retrieve the number of recommended shards- Returns:
- a shard count as a
Mono
to obtain this number asynchronously.
-
getShards
public Flux<ShardInfo> getShards(int shardCount)
Description copied from interface:ShardingStrategy
Return the shard factory used to create a group of sharded clients.- Specified by:
getShards
in interfaceShardingStrategy
- Parameters:
shardCount
- the total number of shards- Returns:
- a shard factory as a sequence of
ShardInfo
items.
-
getGroupManager
public discord4j.core.shard.GatewayClientGroupManager getGroupManager(int count)
Description copied from interface:ShardingStrategy
Return theGatewayClientGroupManager
to maintain each gateway client in the created group.- Specified by:
getGroupManager
in interfaceShardingStrategy
- Parameters:
count
- the total number of shards- Returns:
- a
GatewayClientGroupManager
used by this strategy
-
getMaxConcurrency
public int getMaxConcurrency()
Description copied from interface:ShardingStrategy
Return 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:
getMaxConcurrency
in interfaceShardingStrategy
- Returns:
- a value determining the sharding factor this strategy has
- See Also:
- Sharding for very large bots
-
-