Skip to content

Commit

Permalink
registered ChannelWriter and ChannelReader
Browse files Browse the repository at this point in the history
  • Loading branch information
granstel committed Mar 27, 2024
1 parent f9ba831 commit f1fbc06
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Dodo1000Bot.Api/DependencyModules/JobsRegistration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Threading.Channels;
using Dodo1000Bot.Api.Jobs;
using Dodo1000Bot.Models.Domain;
using Dodo1000Bot.Services.Configuration;
using Microsoft.Extensions.DependencyInjection;

Expand All @@ -11,8 +13,22 @@ internal static void AddJobs(this IServiceCollection services, AppConfiguration
services.AddHostedService(serviceProvider => new MigrationsJob(appConfiguration.MysqlConnectionString, serviceProvider));
services.AddHostedService<FirstRunJob>();
services.AddHostedService<PushNotificationsRepeatableJob>();

services.AddHostedService<UnitsCheckAndNotifyJob>();
services.AddHostedService<StatisticsCheckAndNotifyJob>();
services.AddHostedService<YoutubeCheckAndNotifyJob>();

var channelOptions = new BoundedChannelOptions(1_000)
{
FullMode = BoundedChannelFullMode.DropWrite,
SingleReader = true,
SingleWriter = true
};
var channel = Channel.CreateBounded<Notification>(channelOptions);

services.AddSingleton<ChannelWriter<Notification>>(channel);
services.AddSingleton<ChannelReader<Notification>>(channel);

services.AddHostedService<PushNotificationsJob>();
}
}

0 comments on commit f1fbc06

Please sign in to comment.