Package discord4j.core.shard
Interface ShardingStrategy
- All Known Implementing Classes:
DefaultShardingStrategy
public interface ShardingStrategy
Strategy to build sharding
GatewayClient
instances.-
Method Summary
Modifier and TypeMethodDescriptionbuilder()
Return a builder to customize theShardingStrategy
using commonly used parameters.static ShardingStrategy
fixed
(int count) Sharding strategy that creates a fixed number ofGatewayClient
instances, using the givencount
.discord4j.core.shard.GatewayClientGroupManager
getGroupManager
(int shardCount) Return theGatewayClientGroupManager
to maintain each gateway client in the created group.int
Deprecated.getMaxConcurrency
(RestClient restClient) Return the number of shards that can be identified concurrently.getShardCount
(RestClient restClient) Return the shard count used to create a group of sharded clients.getShards
(int shardCount) Return the shard factory used to create a group of sharded clients.static ShardingStrategy
Sharding strategy that retrieves the recommended shard count and concurrency, and creates as manyGatewayClient
instances as indexes given by that count.static ShardingStrategy
single()
Sharding strategy that creates a singleGatewayClient
.
-
Method Details
-
getShardCount
Return the shard count used to create a group of sharded clients.- 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
Return the shard factory used to create a group of sharded clients.- Parameters:
shardCount
- the total number of shards- Returns:
- a shard factory as a sequence of
ShardInfo
items.
-
getGroupManager
discord4j.core.shard.GatewayClientGroupManager getGroupManager(int shardCount) Return theGatewayClientGroupManager
to maintain each gateway client in the created group.- Parameters:
shardCount
- the total number of shards- Returns:
- a
GatewayClientGroupManager
used by this strategy
-
getMaxConcurrency
Deprecated.usegetMaxConcurrency(RestClient)
insteadReturn the number of shards that can be identified concurrently. Must be 1 unless your application is authorized to use the large bot sharding system.- Returns:
- a value determining the sharding factor this strategy has
- See Also:
-
getMaxConcurrency
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.- Parameters:
restClient
- a handle to consume REST API resources, typically to retrieve the recommended concurrency- Returns:
- a value determining the sharding factor this strategy has
- See Also:
-
recommended
Sharding strategy that retrieves the recommended shard count and concurrency, and creates as manyGatewayClient
instances as indexes given by that count.- Returns:
- a recommended
ShardingStrategy
-
fixed
Sharding strategy that creates a fixed number ofGatewayClient
instances, using the givencount
.- Parameters:
count
- the number ofGatewayClient
instances to create, each representing a Discord shard- Returns:
- a fixed-count
ShardingStrategy
-
single
Sharding strategy that creates a singleGatewayClient
. Useful for basic bots or for advanced workerGatewayClient
that do not directly perform authentication to the Discord Gateway.- Returns:
- a simple non-sharded
ShardingStrategy
-
builder
Return a builder to customize theShardingStrategy
using commonly used parameters.- Returns:
- a
DefaultShardingStrategy.Builder
to create a customShardingStrategy
-
getMaxConcurrency(RestClient)
instead