aboutsummaryrefslogtreecommitdiffstats
path: root/code/api/src/Jobs/JobRegister.cs
blob: c07a6d122dcf1633e88eedc5c3c32c10a95c9eae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
using Quartz.Impl;

namespace IOL.GreatOffice.Api.Jobs;

public static class JobRegister
{
    private static readonly JobKey AccessTokenCleanupKey = new("AccessTokenCleanupKey");
    private static readonly JobKey VaultTokenRenewalKey = new("VaultTokenRenewalKey");

    public static IServiceCollectionQuartzConfigurator RegisterJobs(this IServiceCollectionQuartzConfigurator configurator) {
        configurator.AddJob<AccessTokenCleanupJob>(AccessTokenCleanupKey);
        configurator.AddTrigger(options => {
            options.ForJob(AccessTokenCleanupKey)
                .WithIdentity(AccessTokenCleanupKey.Name + "-trigger")
                .WithCronSchedule("0 0 0/1 ? * * *");
        });

        return configurator;
    }
}