44 lines
2.1 KiB
C#
44 lines
2.1 KiB
C#
using Hangfire;
|
|
using Newsbot.Collector.Domain.Consts;
|
|
using Newsbot.Collector.Domain.Models.Config;
|
|
using Newsbot.Collector.Services.Jobs;
|
|
|
|
namespace Newsbot.Collector.Api.Startup;
|
|
|
|
public static class BackgroundJobs
|
|
{
|
|
public static void SetupRecurringJobs(IConfiguration configuration)
|
|
{
|
|
RecurringJob.AddOrUpdate<RssWatcherJob>("RSS", x =>
|
|
x.InitAndExecute(new RssWatcherJobOptions
|
|
{
|
|
ConnectionString = configuration.GetValue<string>(ConfigConst.ConnectionStringDatabase),
|
|
OpenTelemetry = configuration.GetValue<string>(ConfigConst.ConnectionStringOpenTelemetry),
|
|
IsEnabled = configuration.GetValue<bool>(ConfigConst.RssIsEnabled)
|
|
}), "15 0-23 * * *");
|
|
|
|
RecurringJob.AddOrUpdate<YoutubeWatcherJob>("Youtube", x => x.InitAndExecute(new YoutubeWatcherJobOptions
|
|
{
|
|
DatabaseConnectionString = configuration.GetValue<string>(ConfigConst.ConnectionStringDatabase),
|
|
OpenTelemetryConnectionString = configuration.GetValue<string>(ConfigConst.ConnectionStringOpenTelemetry),
|
|
IsEnabled = configuration.GetValue<bool>(ConfigConst.YoutubeIsEnable)
|
|
}), "20 0-23 * * *");
|
|
|
|
RecurringJob.AddOrUpdate<CodeProjectWatcherJob>("CodeProjects", x =>
|
|
x.InitAndExecute(new CodeProjectWatcherJobOptions
|
|
{
|
|
ConnectionStrings = configuration.GetSection(ConfigConst.SectionConnectionStrings)
|
|
.Get<ConfigSectionConnectionStrings>(),
|
|
FeaturePullCommits = true,
|
|
FeaturePullReleases = true
|
|
}), "25 0-23 * * *");
|
|
|
|
RecurringJob.AddOrUpdate<DiscordNotificationJob>("Discord Alerts", x =>
|
|
x.InitAndExecute(new DiscordNotificationJobOptions
|
|
{
|
|
ConnectionString = configuration.GetValue<string>(ConfigConst.ConnectionStringDatabase),
|
|
OpenTelemetry = configuration.GetValue<string>(ConfigConst.ConnectionStringOpenTelemetry),
|
|
IsEnabled = configuration.GetValue<bool>(ConfigConst.DiscordNotificationsEnabled)
|
|
}), "5/10 * * * *");
|
|
}
|
|
} |