Package discord4j.core.shard
Class LocalShardCoordinator
java.lang.Object
discord4j.core.shard.LocalShardCoordinator
- All Implemented Interfaces:
ShardCoordinator
A centralized local
ShardCoordinator
that can operate on a single JVM instance to coordinate Gateway
connection and identifying attempts across multiple shards.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic LocalShardCoordinator
create()
Create a newLocalShardCoordinator
that is able to locally coordinate multiple shards under a single JVM instance.static LocalShardCoordinator
create
(Supplier<PayloadTransformer> identifyLimiterFactory) Create a newLocalShardCoordinator
that is able to locally coordinate multiple shards under a single JVM instance.Return the number of currently connected shards.getIdentifyLimiter
(ShardInfo shardInfo, int maxConcurrency) Returns a transformation function for a sequence of payloads that can be held or delayed in order to successfully identify multiple shards in a coordinated manner.publishConnected
(ShardInfo shardInfo) Notifies this coordinator that a given shard has connected successfully.publishDisconnected
(ShardInfo shardInfo, SessionInfo sessionInfo) Notifies this coordinator that a given shard has disconnected.
-
Field Details
-
DEFAULT_IDENTIFY_LIMITER_FACTORY
-
-
Method Details
-
create
Create a newLocalShardCoordinator
that is able to locally coordinate multiple shards under a single JVM instance. -
create
Create a newLocalShardCoordinator
that is able to locally coordinate multiple shards under a single JVM instance.- Parameters:
identifyLimiterFactory
- a supplier ofPayloadTransformer
instances for limiting IDENTIFY access across buckets.
-
publishConnected
Description copied from interface:ShardCoordinator
Notifies this coordinator that a given shard has connected successfully. Can be used to signal other shards for authentication.- Specified by:
publishConnected
in interfaceShardCoordinator
- Parameters:
shardInfo
- the connected shard details- Returns:
- a
Mono
indicating when this operation has completed
-
publishDisconnected
Description copied from interface:ShardCoordinator
Notifies this coordinator that a given shard has disconnected.- Specified by:
publishDisconnected
in interfaceShardCoordinator
- Parameters:
shardInfo
- the disconnected shard detailssessionInfo
- the disconnected shard session details to resume, ornull
if resume is not available- Returns:
- a
Mono
indicating when this operation has completed
-
getIdentifyLimiter
Description copied from interface:ShardCoordinator
Returns a transformation function for a sequence of payloads that can be held or delayed in order to successfully identify multiple shards in a coordinated manner.- Specified by:
getIdentifyLimiter
in interfaceShardCoordinator
- Parameters:
shardInfo
- the shard from where to retrieve the limitermaxConcurrency
- the number of shards that can be concurrently identified- Returns:
- a
PayloadTransformer
allowing IDENTIFY payload coordination across shards
-
getConnectedCount
Description copied from interface:ShardCoordinator
Return the number of currently connected shards.- Specified by:
getConnectedCount
in interfaceShardCoordinator
- Returns:
- a
Mono
with the number of connected shards
-