From eb0e289393166edcf051fff63e9ca760a1e0c792 Mon Sep 17 00:00:00 2001 From: adrianwium <82496337+adrianwium@users.noreply.github.com> Date: Wed, 10 Apr 2024 10:40:52 +0200 Subject: [PATCH] Added a prefix identifier to redis lock keys (#706) --- .../application/Yoma.Core.Api/Common/Constants.cs | 2 +- .../src/domain/Yoma.Core.Domain/Core/Constants.cs | 3 +-- .../Services/OrganizationBackgroundService.cs | 13 +++++++------ .../Entity/Services/UserBackgroundService.cs | 5 +++-- .../Lookups/Services/SkillService.cs | 5 +++-- .../Services/MyOpportunityBackgroundService.cs | 9 +++++---- .../Services/OpportunityBackgroundService.cs | 13 +++++++------ .../Reward/Services/RewardBackgroundService.cs | 9 +++++---- .../SSI/Services/SSIBackgroundService.cs | 13 +++++++------ 9 files changed, 39 insertions(+), 33 deletions(-) diff --git a/src/api/src/application/Yoma.Core.Api/Common/Constants.cs b/src/api/src/application/Yoma.Core.Api/Common/Constants.cs index f93243cc8..06c2d7688 100644 --- a/src/api/src/application/Yoma.Core.Api/Common/Constants.cs +++ b/src/api/src/application/Yoma.Core.Api/Common/Constants.cs @@ -1,6 +1,6 @@ namespace Yoma.Core.Api.Common { - internal class Constants + internal static class Constants { internal const string RequestHeader_ApiKey = "X-ApiKey"; internal const string Authorization_Policy = "yoma_core_api"; diff --git a/src/api/src/domain/Yoma.Core.Domain/Core/Constants.cs b/src/api/src/domain/Yoma.Core.Domain/Core/Constants.cs index b2bd1aa41..d3505e353 100644 --- a/src/api/src/domain/Yoma.Core.Domain/Core/Constants.cs +++ b/src/api/src/domain/Yoma.Core.Domain/Core/Constants.cs @@ -5,9 +5,8 @@ public static class Constants public const string Role_User = "User"; public const string Role_Admin = "Admin"; public const string Role_OrganizationAdmin = "OrganisationAdmin"; - public static readonly string[] Roles_Supported = [Role_User, Role_Admin, Role_OrganizationAdmin]; - public const string ModifiedBy_System_Username = "system@yoma.world"; + public const string Redis_LockIdentifier_Prefix = "yoma.api.core:locks:"; } } diff --git a/src/api/src/domain/Yoma.Core.Domain/Entity/Services/OrganizationBackgroundService.cs b/src/api/src/domain/Yoma.Core.Domain/Entity/Services/OrganizationBackgroundService.cs index 35565429c..2d6794893 100644 --- a/src/api/src/domain/Yoma.Core.Domain/Entity/Services/OrganizationBackgroundService.cs +++ b/src/api/src/domain/Yoma.Core.Domain/Entity/Services/OrganizationBackgroundService.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using System.Reflection; +using Yoma.Core.Domain.Core; using Yoma.Core.Domain.Core.Helpers; using Yoma.Core.Domain.Core.Interfaces; using Yoma.Core.Domain.Core.Models; @@ -65,7 +66,7 @@ public OrganizationBackgroundService(ILogger logg #region Public Memebers public async Task ProcessDeclination() { - const string lockIdentifier = "organization_process_declination"; + const string lockIdentifier = $"{Constants.Redis_LockIdentifier_Prefix}organization_process_declination"; var dateTimeNow = DateTimeOffset.UtcNow; var executeUntil = dateTimeNow.AddHours(_scheduleJobOptions.DefaultScheduleMaxIntervalInHours); var lockDuration = executeUntil - dateTimeNow + TimeSpan.FromMinutes(_scheduleJobOptions.DistributedLockDurationBufferInMinutes); @@ -81,7 +82,7 @@ public async Task ProcessDeclination() using (JobStorage.Current.GetConnection().AcquireDistributedLock(lockIdentifier, lockDuration)) { _logger.LogInformation("Lock '{lockIdentifier}' acquired by {hostName} at {dateStamp}. Lock duration set to {lockDurationInMinutes} minutes", - lockIdentifier, Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); + lockIdentifier, System.Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); _logger.LogInformation("Processing organization declination"); @@ -163,7 +164,7 @@ public async Task ProcessDeclination() public async Task ProcessDeletion() { - const string lockIdentifier = "organization_process_deletion"; + const string lockIdentifier = $"{Constants.Redis_LockIdentifier_Prefix}organization_process_deletion"; var dateTimeNow = DateTimeOffset.UtcNow; var executeUntil = dateTimeNow.AddHours(_scheduleJobOptions.DefaultScheduleMaxIntervalInHours); var lockDuration = executeUntil - dateTimeNow + TimeSpan.FromMinutes(_scheduleJobOptions.DistributedLockDurationBufferInMinutes); @@ -179,7 +180,7 @@ public async Task ProcessDeletion() using (JobStorage.Current.GetConnection().AcquireDistributedLock(lockIdentifier, lockDuration)) { _logger.LogInformation("Lock '{lockIdentifier}' acquired by {hostName} at {dateStamp}. Lock duration set to {lockDurationInMinutes} minutes", - lockIdentifier, Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); + lockIdentifier, System.Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); _logger.LogInformation("Processing organization deletion"); @@ -226,7 +227,7 @@ public async Task ProcessDeletion() public async Task SeedLogoAndDocuments() { - const string lockIdentifier = "organization_seed_logos_and_documents"; + const string lockIdentifier = $"{Constants.Redis_LockIdentifier_Prefix}organization_seed_logos_and_documents"; var lockDuration = TimeSpan.FromHours(_scheduleJobOptions.DefaultScheduleMaxIntervalInHours) + TimeSpan.FromMinutes(_scheduleJobOptions.DistributedLockDurationBufferInMinutes); if (!await _distributedLockService.TryAcquireLockAsync(lockIdentifier, lockDuration)) @@ -240,7 +241,7 @@ public async Task SeedLogoAndDocuments() using (JobStorage.Current.GetConnection().AcquireDistributedLock(lockIdentifier, lockDuration)) { _logger.LogInformation("Lock '{lockIdentifier}' acquired by {hostName} at {dateStamp}. Lock duration set to {lockDurationInMinutes} minutes", - lockIdentifier, Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); + lockIdentifier, System.Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); if (!_appSettings.TestDataSeedingEnvironmentsAsEnum.HasFlag(_environmentProvider.Environment)) { diff --git a/src/api/src/domain/Yoma.Core.Domain/Entity/Services/UserBackgroundService.cs b/src/api/src/domain/Yoma.Core.Domain/Entity/Services/UserBackgroundService.cs index 711642375..21cdb5eeb 100644 --- a/src/api/src/domain/Yoma.Core.Domain/Entity/Services/UserBackgroundService.cs +++ b/src/api/src/domain/Yoma.Core.Domain/Entity/Services/UserBackgroundService.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using System.Reflection; +using Yoma.Core.Domain.Core; using Yoma.Core.Domain.Core.Helpers; using Yoma.Core.Domain.Core.Interfaces; using Yoma.Core.Domain.Core.Models; @@ -45,7 +46,7 @@ public UserBackgroundService(ILogger logger, #region Public Members public async Task SeedPhotos() { - const string lockIdentifier = "user_seed_photos"; + const string lockIdentifier = $"{Constants.Redis_LockIdentifier_Prefix}user_seed_photos"; var lockDuration = TimeSpan.FromHours(_scheduleJobOptions.DefaultScheduleMaxIntervalInHours) + TimeSpan.FromMinutes(_scheduleJobOptions.DistributedLockDurationBufferInMinutes); if (!await _distributedLockService.TryAcquireLockAsync(lockIdentifier, lockDuration)) @@ -59,7 +60,7 @@ public async Task SeedPhotos() using (JobStorage.Current.GetConnection().AcquireDistributedLock(lockIdentifier, lockDuration)) { _logger.LogInformation("Lock '{lockIdentifier}' acquired by {hostName} at {dateStamp}. Lock duration set to {lockDurationInMinutes} minutes", - lockIdentifier, Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); + lockIdentifier, System.Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); if (!_appSettings.TestDataSeedingEnvironmentsAsEnum.HasFlag(_environmentProvider.Environment)) { diff --git a/src/api/src/domain/Yoma.Core.Domain/Lookups/Services/SkillService.cs b/src/api/src/domain/Yoma.Core.Domain/Lookups/Services/SkillService.cs index 79a00a601..f32254f2c 100644 --- a/src/api/src/domain/Yoma.Core.Domain/Lookups/Services/SkillService.cs +++ b/src/api/src/domain/Yoma.Core.Domain/Lookups/Services/SkillService.cs @@ -3,6 +3,7 @@ using Hangfire.Storage; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using Yoma.Core.Domain.Core; using Yoma.Core.Domain.Core.Interfaces; using Yoma.Core.Domain.Core.Models; using Yoma.Core.Domain.LaborMarketProvider.Interfaces; @@ -108,7 +109,7 @@ public SkillSearchResults Search(SkillSearchFilter filter) public async Task SeedSkills(bool onStartupInitialSeeding) { - const string lockIdentifier = "skill_seed"; + const string lockIdentifier = $"{Constants.Redis_LockIdentifier_Prefix}skill_seed"; var lockDuration = TimeSpan.FromHours(_scheduleJobOptions.DefaultScheduleMaxIntervalInHours) + TimeSpan.FromMinutes(_scheduleJobOptions.DistributedLockDurationBufferInMinutes); if (!await _distributedLockService.TryAcquireLockAsync(lockIdentifier, lockDuration)) @@ -122,7 +123,7 @@ public async Task SeedSkills(bool onStartupInitialSeeding) using (JobStorage.Current.GetConnection().AcquireDistributedLock(lockIdentifier, lockDuration)) { _logger.LogInformation("Lock '{lockIdentifier}' acquired by {hostName} at {dateStamp}. Lock duration set to {lockDurationInMinutes} minutes", - lockIdentifier, Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); + lockIdentifier, System.Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); try { diff --git a/src/api/src/domain/Yoma.Core.Domain/MyOpportunity/Services/MyOpportunityBackgroundService.cs b/src/api/src/domain/Yoma.Core.Domain/MyOpportunity/Services/MyOpportunityBackgroundService.cs index 4d3412292..d9d057446 100644 --- a/src/api/src/domain/Yoma.Core.Domain/MyOpportunity/Services/MyOpportunityBackgroundService.cs +++ b/src/api/src/domain/Yoma.Core.Domain/MyOpportunity/Services/MyOpportunityBackgroundService.cs @@ -4,6 +4,7 @@ using Microsoft.Extensions.Options; using System.ComponentModel.DataAnnotations; using System.Reflection; +using Yoma.Core.Domain.Core; using Yoma.Core.Domain.Core.Helpers; using Yoma.Core.Domain.Core.Interfaces; using Yoma.Core.Domain.Core.Models; @@ -71,7 +72,7 @@ public MyOpportunityBackgroundService(ILogger lo #region Public Members public async Task ProcessVerificationRejection() { - const string lockIdentifier = "myopportunity_process_verification_rejection"; + const string lockIdentifier = $"{Constants.Redis_LockIdentifier_Prefix}myopportunity_process_verification_rejection"; var dateTimeNow = DateTimeOffset.UtcNow; var executeUntil = dateTimeNow.AddHours(_scheduleJobOptions.DefaultScheduleMaxIntervalInHours); var lockDuration = executeUntil - dateTimeNow + TimeSpan.FromMinutes(_scheduleJobOptions.DistributedLockDurationBufferInMinutes); @@ -87,7 +88,7 @@ public async Task ProcessVerificationRejection() using (JobStorage.Current.GetConnection().AcquireDistributedLock(lockIdentifier, lockDuration)) { _logger.LogInformation("Lock '{lockIdentifier}' acquired by {hostName} at {dateStamp}. Lock duration set to {lockDurationInMinutes} minutes", - lockIdentifier, Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); + lockIdentifier, System.Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); _logger.LogInformation("Processing 'my' opportunity verification rejection"); @@ -174,7 +175,7 @@ public async Task ProcessVerificationRejection() public async Task SeedPendingVerifications() { - const string lockIdentifier = "myopportunity_seed_pending_verifications]"; + const string lockIdentifier = $"{Constants.Redis_LockIdentifier_Prefix}myopportunity_seed_pending_verifications]"; var lockDuration = TimeSpan.FromHours(_scheduleJobOptions.DefaultScheduleMaxIntervalInHours) + TimeSpan.FromMinutes(_scheduleJobOptions.DistributedLockDurationBufferInMinutes); if (!await _distributedLockService.TryAcquireLockAsync(lockIdentifier, lockDuration)) @@ -188,7 +189,7 @@ public async Task SeedPendingVerifications() using (JobStorage.Current.GetConnection().AcquireDistributedLock(lockIdentifier, lockDuration)) { _logger.LogInformation("Lock '{lockIdentifier}' acquired by {hostName} at {dateStamp}. Lock duration set to {lockDurationInMinutes} minutes", - lockIdentifier, Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); + lockIdentifier, System.Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); if (!_appSettings.TestDataSeedingEnvironmentsAsEnum.HasFlag(_environmentProvider.Environment)) { diff --git a/src/api/src/domain/Yoma.Core.Domain/Opportunity/Services/OpportunityBackgroundService.cs b/src/api/src/domain/Yoma.Core.Domain/Opportunity/Services/OpportunityBackgroundService.cs index 6cf0964ac..0598708a9 100644 --- a/src/api/src/domain/Yoma.Core.Domain/Opportunity/Services/OpportunityBackgroundService.cs +++ b/src/api/src/domain/Yoma.Core.Domain/Opportunity/Services/OpportunityBackgroundService.cs @@ -2,6 +2,7 @@ using Hangfire.Storage; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using Yoma.Core.Domain.Core; using Yoma.Core.Domain.Core.Helpers; using Yoma.Core.Domain.Core.Interfaces; using Yoma.Core.Domain.Core.Models; @@ -56,7 +57,7 @@ public OpportunityBackgroundService(ILogger logger #region Public Members public async Task ProcessExpiration() { - const string lockIdentifier = "opporrtunity_process_expiration"; + const string lockIdentifier = $"{Constants.Redis_LockIdentifier_Prefix}opportunity_process_expiration"; var dateTimeNow = DateTimeOffset.UtcNow; var executeUntil = dateTimeNow.AddHours(_scheduleJobOptions.DefaultScheduleMaxIntervalInHours); var lockDuration = executeUntil - dateTimeNow + TimeSpan.FromMinutes(_scheduleJobOptions.DistributedLockDurationBufferInMinutes); @@ -72,7 +73,7 @@ public async Task ProcessExpiration() using (JobStorage.Current.GetConnection().AcquireDistributedLock(lockIdentifier, lockDuration)) { _logger.LogInformation("Lock '{lockIdentifier}' acquired by {hostName} at {dateStamp}. Lock duration set to {lockDurationInMinutes} minutes", - lockIdentifier, Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); + lockIdentifier, System.Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); _logger.LogInformation("Processing opportunity expiration"); @@ -120,7 +121,7 @@ public async Task ProcessExpiration() public async Task ProcessExpirationNotifications() { - const string lockIdentifier = "opporrtunity_process_expiration_notifications"; + const string lockIdentifier = $"{Constants.Redis_LockIdentifier_Prefix}opportunity_process_expiration_notifications"; var lockDuration = TimeSpan.FromHours(_scheduleJobOptions.DefaultScheduleMaxIntervalInHours) + TimeSpan.FromMinutes(_scheduleJobOptions.DistributedLockDurationBufferInMinutes); if (!await _distributedLockService.TryAcquireLockAsync(lockIdentifier, lockDuration)) @@ -134,7 +135,7 @@ public async Task ProcessExpirationNotifications() using (JobStorage.Current.GetConnection().AcquireDistributedLock(lockIdentifier, lockDuration)) { _logger.LogInformation("Lock '{lockIdentifier}' acquired by {hostName} at {dateStamp}. Lock duration set to {lockDurationInMinutes} minutes", - lockIdentifier, Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); + lockIdentifier, System.Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); _logger.LogInformation("Processing opportunity expiration notifications"); @@ -168,7 +169,7 @@ public async Task ProcessExpirationNotifications() public async Task ProcessDeletion() { - const string lockIdentifier = "opporrtunity_process_deletion"; + const string lockIdentifier = $"{Constants.Redis_LockIdentifier_Prefix}opportunity_process_deletion"; var dateTimeNow = DateTimeOffset.UtcNow; var executeUntil = dateTimeNow.AddHours(_scheduleJobOptions.DefaultScheduleMaxIntervalInHours); var lockDuration = executeUntil - dateTimeNow + TimeSpan.FromMinutes(_scheduleJobOptions.DistributedLockDurationBufferInMinutes); @@ -184,7 +185,7 @@ public async Task ProcessDeletion() using (JobStorage.Current.GetConnection().AcquireDistributedLock(lockIdentifier, lockDuration)) { _logger.LogInformation("Lock '{lockIdentifier}' acquired by {hostName} at {dateStamp}. Lock duration set to {lockDurationInMinutes} minutes", - lockIdentifier, Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); + lockIdentifier, System.Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); _logger.LogInformation("Processing opportunity deletion"); diff --git a/src/api/src/domain/Yoma.Core.Domain/Reward/Services/RewardBackgroundService.cs b/src/api/src/domain/Yoma.Core.Domain/Reward/Services/RewardBackgroundService.cs index 16f02d97d..84afc17f0 100644 --- a/src/api/src/domain/Yoma.Core.Domain/Reward/Services/RewardBackgroundService.cs +++ b/src/api/src/domain/Yoma.Core.Domain/Reward/Services/RewardBackgroundService.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using System.Transactions; +using Yoma.Core.Domain.Core; using Yoma.Core.Domain.Core.Interfaces; using Yoma.Core.Domain.Core.Models; using Yoma.Core.Domain.MyOpportunity.Interfaces; @@ -56,7 +57,7 @@ public RewardBackgroundService(ILogger logger, #region Public Members public async Task ProcessWalletCreation() { - const string lockIdentifier = "reward_process_wallet_creation"; + const string lockIdentifier = $"{Constants.Redis_LockIdentifier_Prefix}reward_process_wallet_creation"; var dateTimeNow = DateTimeOffset.UtcNow; var executeUntil = dateTimeNow.AddHours(_scheduleJobOptions.RewardWalletCreationScheduleMaxIntervalInHours); var lockDuration = executeUntil - dateTimeNow + TimeSpan.FromMinutes(_scheduleJobOptions.DistributedLockDurationBufferInMinutes); @@ -72,7 +73,7 @@ public async Task ProcessWalletCreation() using (JobStorage.Current.GetConnection().AcquireDistributedLock(lockIdentifier, lockDuration)) { _logger.LogInformation("Lock '{lockIdentifier}' acquired by {hostName} at {dateStamp}. Lock duration set to {lockDurationInMinutes} minutes", - lockIdentifier, Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); + lockIdentifier, System.Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); _logger.LogInformation("Processing Reward wallet creation"); @@ -138,7 +139,7 @@ await _executionStrategyService.ExecuteInExecutionStrategyAsync(async () => public async Task ProcessRewardTransactions() { - const string lockIdentifier = "reward_process_transactions"; + const string lockIdentifier = $"{Constants.Redis_LockIdentifier_Prefix}reward_process_transactions"; var dateTimeNow = DateTimeOffset.UtcNow; var executeUntil = dateTimeNow.AddHours(_scheduleJobOptions.RewardTransactionScheduleMaxIntervalInHours); var lockDuration = executeUntil - dateTimeNow + TimeSpan.FromMinutes(_scheduleJobOptions.DistributedLockDurationBufferInMinutes); @@ -154,7 +155,7 @@ public async Task ProcessRewardTransactions() using (JobStorage.Current.GetConnection().AcquireDistributedLock(lockIdentifier, lockDuration)) { _logger.LogInformation("Lock '{lockIdentifier}' acquired by {hostName} at {dateStamp}. Lock duration set to {lockDurationInMinutes} minutes", - lockIdentifier, Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); + lockIdentifier, System.Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); _logger.LogInformation("Processing reward transactions"); diff --git a/src/api/src/domain/Yoma.Core.Domain/SSI/Services/SSIBackgroundService.cs b/src/api/src/domain/Yoma.Core.Domain/SSI/Services/SSIBackgroundService.cs index dd1016ee3..37cab095d 100644 --- a/src/api/src/domain/Yoma.Core.Domain/SSI/Services/SSIBackgroundService.cs +++ b/src/api/src/domain/Yoma.Core.Domain/SSI/Services/SSIBackgroundService.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using System.Collections; +using Yoma.Core.Domain.Core; using Yoma.Core.Domain.Core.Extensions; using Yoma.Core.Domain.Core.Interfaces; using Yoma.Core.Domain.Core.Models; @@ -72,7 +73,7 @@ public SSIBackgroundService(ILogger logger, /// public async Task SeedSchemas() { - const string lockIdentifier = "ssi_seed_schemas"; + const string lockIdentifier = $"{Constants.Redis_LockIdentifier_Prefix}ssi_seed_schemas"; var lockDuration = TimeSpan.FromHours(_scheduleJobOptions.DefaultScheduleMaxIntervalInHours) + TimeSpan.FromMinutes(_scheduleJobOptions.DistributedLockDurationBufferInMinutes); if (!await _distributedLockService.TryAcquireLockAsync(lockIdentifier, lockDuration)) @@ -86,7 +87,7 @@ public async Task SeedSchemas() using (JobStorage.Current.GetConnection().AcquireDistributedLock(lockIdentifier, lockDuration)) { _logger.LogInformation("Lock '{lockIdentifier}' acquired by {hostName} at {dateStamp}. Lock duration set to {lockDurationInMinutes} minutes", - lockIdentifier, Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); + lockIdentifier, System.Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); _logger.LogInformation("Processing SSI default schema seeding"); @@ -117,7 +118,7 @@ await SeedSchema(ArtifactType.Indy, public async Task ProcessTenantCreation() { - const string lockIdentifier = "ssi_process_tenant_creation"; + const string lockIdentifier = $"{Constants.Redis_LockIdentifier_Prefix}ssi_process_tenant_creation"; var dateTimeNow = DateTimeOffset.UtcNow; var executeUntil = dateTimeNow.AddHours(_scheduleJobOptions.SSITenantCreationScheduleMaxIntervalInHours); var lockDuration = executeUntil - dateTimeNow + TimeSpan.FromMinutes(_scheduleJobOptions.DistributedLockDurationBufferInMinutes); @@ -133,7 +134,7 @@ public async Task ProcessTenantCreation() using (JobStorage.Current.GetConnection().AcquireDistributedLock(lockIdentifier, lockDuration)) { _logger.LogInformation("Lock '{lockIdentifier}' acquired by {hostName} at {dateStamp}. Lock duration set to {lockDurationInMinutes} minutes", - lockIdentifier, Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); + lockIdentifier, System.Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); _logger.LogInformation("Processing SSI tenant creation"); @@ -229,7 +230,7 @@ public async Task ProcessTenantCreation() public async Task ProcessCredentialIssuance() { - const string lockIdentifier = "ssi_process_credential_issuance"; + const string lockIdentifier = $"{Constants.Redis_LockIdentifier_Prefix}ssi_process_credential_issuance"; var dateTimeNow = DateTimeOffset.UtcNow; var executeUntil = dateTimeNow.AddHours(_scheduleJobOptions.SSICredentialIssuanceScheduleMaxIntervalInHours); var lockDuration = executeUntil - dateTimeNow + TimeSpan.FromMinutes(_scheduleJobOptions.DistributedLockDurationBufferInMinutes); @@ -245,7 +246,7 @@ public async Task ProcessCredentialIssuance() using (JobStorage.Current.GetConnection().AcquireDistributedLock(lockIdentifier, lockDuration)) { _logger.LogInformation("Lock '{lockIdentifier}' acquired by {hostName} at {dateStamp}. Lock duration set to {lockDurationInMinutes} minutes", - lockIdentifier, Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); + lockIdentifier, System.Environment.MachineName, DateTimeOffset.UtcNow, lockDuration.TotalMinutes); _logger.LogInformation("Processing SSI credential issuance");