Interface ShardingStrategy

    • Method Detail

      • getShardCount

        Mono<Integer> getShardCount​(RestClient restClient)
        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

        default Flux<ShardInfo> getShards​(int shardCount)
        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 the GatewayClientGroupManager 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
        int getMaxConcurrency()
        Deprecated.
        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.
        Returns:
        a value determining the sharding factor this strategy has
        See Also:
        Sharding for very large bots
      • getMaxConcurrency

        default Mono<Integer> getMaxConcurrency​(RestClient restClient)
        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:
        Sharding for very large bots
      • recommended

        static ShardingStrategy recommended()
        Sharding strategy that retrieves the recommended shard count and concurrency, and creates as many GatewayClient instances as indexes given by that count.
        Returns:
        a recommended ShardingStrategy
      • fixed

        static ShardingStrategy fixed​(int count)
        Sharding strategy that creates a fixed number of GatewayClient instances, using the given count.
        Parameters:
        count - the number of GatewayClient instances to create, each representing a Discord shard
        Returns:
        a fixed-count ShardingStrategy