mirror of
https://github.com/bitwarden/server.git
synced 2025-01-22 21:51:22 +01:00
Added quartz support to the Billing project (#5186)
This commit is contained in:
parent
11325c4d3f
commit
adfe365db9
13
src/Billing/Jobs/AliveJob.cs
Normal file
13
src/Billing/Jobs/AliveJob.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using Bit.Core.Jobs;
|
||||||
|
using Quartz;
|
||||||
|
|
||||||
|
namespace Bit.Billing.Jobs;
|
||||||
|
|
||||||
|
public class AliveJob(ILogger<AliveJob> logger) : BaseJob(logger)
|
||||||
|
{
|
||||||
|
protected override Task ExecuteJobAsync(IJobExecutionContext context)
|
||||||
|
{
|
||||||
|
_logger.LogInformation(Core.Constants.BypassFiltersEventId, null, "Billing service is alive!");
|
||||||
|
return Task.FromResult(0);
|
||||||
|
}
|
||||||
|
}
|
36
src/Billing/Jobs/JobsHostedService.cs
Normal file
36
src/Billing/Jobs/JobsHostedService.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using Bit.Core.Jobs;
|
||||||
|
using Bit.Core.Settings;
|
||||||
|
using Quartz;
|
||||||
|
|
||||||
|
namespace Bit.Billing.Jobs;
|
||||||
|
|
||||||
|
public class JobsHostedService : BaseJobsHostedService
|
||||||
|
{
|
||||||
|
public JobsHostedService(
|
||||||
|
GlobalSettings globalSettings,
|
||||||
|
IServiceProvider serviceProvider,
|
||||||
|
ILogger<JobsHostedService> logger,
|
||||||
|
ILogger<JobListener> listenerLogger)
|
||||||
|
: base(globalSettings, serviceProvider, logger, listenerLogger) { }
|
||||||
|
|
||||||
|
public override async Task StartAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var everyTopOfTheHourTrigger = TriggerBuilder.Create()
|
||||||
|
.WithIdentity("EveryTopOfTheHourTrigger")
|
||||||
|
.StartNow()
|
||||||
|
.WithCronSchedule("0 0 * * * ?")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
Jobs = new List<Tuple<Type, ITrigger>>
|
||||||
|
{
|
||||||
|
new Tuple<Type, ITrigger>(typeof(AliveJob), everyTopOfTheHourTrigger)
|
||||||
|
};
|
||||||
|
|
||||||
|
await base.StartAsync(cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddJobsServices(IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddTransient<AliveJob>();
|
||||||
|
}
|
||||||
|
}
|
@ -100,6 +100,10 @@ public class Startup
|
|||||||
services.AddScoped<IStripeFacade, StripeFacade>();
|
services.AddScoped<IStripeFacade, StripeFacade>();
|
||||||
services.AddScoped<IStripeEventService, StripeEventService>();
|
services.AddScoped<IStripeEventService, StripeEventService>();
|
||||||
services.AddScoped<IProviderEventService, ProviderEventService>();
|
services.AddScoped<IProviderEventService, ProviderEventService>();
|
||||||
|
|
||||||
|
// Jobs service
|
||||||
|
Jobs.JobsHostedService.AddJobsServices(services);
|
||||||
|
services.AddHostedService<Jobs.JobsHostedService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(
|
public void Configure(
|
||||||
|
Loading…
Reference in New Issue
Block a user