Package discord4j.core.shard
Interface ShardCoordinator
- All Known Implementing Classes:
LocalShardCoordinator
public interface ShardCoordinator
A
ShardCoordinator
defines key operations to leverage shard coordination across boundaries.-
Method Summary
Modifier and TypeMethodDescriptionReturn 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.
-
Method Details
-
getIdentifyLimiter
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.- 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
-
publishConnected
Notifies this coordinator that a given shard has connected successfully. Can be used to signal other shards for authentication.- Parameters:
shardInfo
- the connected shard details- Returns:
- a
Mono
indicating when this operation has completed
-
publishDisconnected
Notifies this coordinator that a given shard has disconnected.- 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
-
getConnectedCount
Return the number of currently connected shards.- Returns:
- a
Mono
with the number of connected shards
-