diff options
| author | ivar <i@oiee.no> | 2023-11-12 00:01:31 +0100 |
|---|---|---|
| committer | ivar <i@oiee.no> | 2023-11-12 00:01:31 +0100 |
| commit | a9f9650400ed9e7f40db5ec5fd08a861f4c30902 (patch) | |
| tree | 7df4e6a086acc21a5b47b4fae8bf395f79061f29 /code/api/src/Jobs | |
| parent | 854dedead3a3ed987997a0132f527db73b65b0ac (diff) | |
| download | greatoffice-a9f9650400ed9e7f40db5ec5fd08a861f4c30902.tar.xz greatoffice-a9f9650400ed9e7f40db5ec5fd08a861f4c30902.zip | |
Change how config is operated
Diffstat (limited to 'code/api/src/Jobs')
| -rw-r--r-- | code/api/src/Jobs/JobRegister.cs | 9 | ||||
| -rw-r--r-- | code/api/src/Jobs/VaultTokenRenewalJob.cs | 24 |
2 files changed, 3 insertions, 30 deletions
diff --git a/code/api/src/Jobs/JobRegister.cs b/code/api/src/Jobs/JobRegister.cs index 1da7d5b..c07a6d1 100644 --- a/code/api/src/Jobs/JobRegister.cs +++ b/code/api/src/Jobs/JobRegister.cs @@ -1,3 +1,5 @@ +using Quartz.Impl; + namespace IOL.GreatOffice.Api.Jobs; public static class JobRegister @@ -7,17 +9,12 @@ public static class JobRegister public static IServiceCollectionQuartzConfigurator RegisterJobs(this IServiceCollectionQuartzConfigurator configurator) { configurator.AddJob<AccessTokenCleanupJob>(AccessTokenCleanupKey); - configurator.AddJob<VaultTokenRenewalJob>(VaultTokenRenewalKey); configurator.AddTrigger(options => { options.ForJob(AccessTokenCleanupKey) .WithIdentity(AccessTokenCleanupKey.Name + "-trigger") .WithCronSchedule("0 0 0/1 ? * * *"); }); - configurator.AddTrigger(options => { - options.ForJob(VaultTokenRenewalKey) - .WithIdentity(VaultTokenRenewalKey.Name + "-trigger") - .WithCronSchedule("0 0 0/1 ? * * *"); - }); + return configurator; } }
\ No newline at end of file diff --git a/code/api/src/Jobs/VaultTokenRenewalJob.cs b/code/api/src/Jobs/VaultTokenRenewalJob.cs deleted file mode 100644 index 1768629..0000000 --- a/code/api/src/Jobs/VaultTokenRenewalJob.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace IOL.GreatOffice.Api.Jobs; - -public class VaultTokenRenewalJob : IJob -{ - private readonly ILogger<VaultTokenRenewalJob> _logger; - private readonly VaultService _vaultService; - - public VaultTokenRenewalJob(ILogger<VaultTokenRenewalJob> logger, VaultService vaultService) { - _logger = logger; - _vaultService = vaultService; - } - - public async Task Execute(IJobExecutionContext context) { - _logger.LogInformation("Starting vault token renewal"); - var renew = await _vaultService.RenewTokenAsync(); - if (renew == default) { - _logger.LogCritical("Renewal did not succeed"); - return; - } - - var token = await _vaultService.LookupTokenAsync(); - _logger.LogInformation("Token was renewed, new expire time {expires}", token.Data.ExpireTime); - } -}
\ No newline at end of file |
