feat: add sharding support
This commit is contained in:
parent
8f39d85486
commit
c42ca3f888
7 changed files with 167 additions and 9 deletions
|
|
@ -1,3 +1,4 @@
|
|||
using Catalogger.Backend.Bot;
|
||||
using Catalogger.Backend.Bot.Commands;
|
||||
using Catalogger.Backend.Bot.Responders.Messages;
|
||||
using Catalogger.Backend.Cache;
|
||||
|
|
@ -12,6 +13,7 @@ using NodaTime;
|
|||
using Remora.Discord.API;
|
||||
using Remora.Discord.API.Abstractions.Rest;
|
||||
using Remora.Discord.Commands.Services;
|
||||
using Remora.Discord.Gateway.Extensions;
|
||||
using Remora.Discord.Interactivity.Services;
|
||||
using Remora.Rest.Core;
|
||||
using Serilog;
|
||||
|
|
@ -81,6 +83,13 @@ public static class StartupExtensions
|
|||
.AddSingleton<GuildFetchService>()
|
||||
.AddHostedService(serviceProvider => serviceProvider.GetRequiredService<GuildFetchService>());
|
||||
|
||||
public static IHostBuilder AddShardedDiscordService(this IHostBuilder builder,
|
||||
Func<IServiceProvider, string> tokenFactory) =>
|
||||
builder.ConfigureServices((_, services) => services
|
||||
.AddDiscordGateway(tokenFactory)
|
||||
.AddSingleton<ShardedGatewayClient>()
|
||||
.AddHostedService<ShardedDiscordService>());
|
||||
|
||||
public static IServiceCollection MaybeAddRedisCaches(this IServiceCollection services, Config config)
|
||||
{
|
||||
if (config.Database.Redis == null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue