mirror of
https://github.com/bitwarden/server
synced 2026-01-07 19:13:50 +00:00
keep application cache in sync with service bus
This commit is contained in:
@@ -501,5 +501,27 @@ namespace Bit.Core.Utilities
|
||||
|
||||
return !invalid;
|
||||
}
|
||||
|
||||
public static string GetApplicationCacheServiceBusSubcriptionName(GlobalSettings globalSettings)
|
||||
{
|
||||
var subName = globalSettings.ServiceBus.ApplicationCacheSubscriptionName;
|
||||
if(string.IsNullOrWhiteSpace(subName))
|
||||
{
|
||||
var websiteInstanceId = Environment.GetEnvironmentVariable("WEBSITE_INSTANCE_ID");
|
||||
if(string.IsNullOrWhiteSpace(websiteInstanceId))
|
||||
{
|
||||
throw new Exception("No service bus subscription name available.");
|
||||
}
|
||||
else
|
||||
{
|
||||
subName = $"{globalSettings.ProjectName.ToLower()}_{websiteInstanceId}";
|
||||
if(subName.Length > 50)
|
||||
{
|
||||
subName = subName.Substring(0, 50);
|
||||
}
|
||||
}
|
||||
}
|
||||
return subName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,16 @@ namespace Bit.Core.Utilities
|
||||
services.AddSingleton<IPaymentService, StripePaymentService>();
|
||||
services.AddSingleton<IMailService, HandlebarsMailService>();
|
||||
services.AddSingleton<ILicensingService, LicensingService>();
|
||||
services.AddSingleton<IApplicationCacheService, InMemoryApplicationCacheService>();
|
||||
|
||||
if(CoreHelpers.SettingHasValue(globalSettings.ServiceBus.ConnectionString) &&
|
||||
CoreHelpers.SettingHasValue(globalSettings.ServiceBus.ApplicationCacheTopicName))
|
||||
{
|
||||
services.AddSingleton<IApplicationCacheService, InMemoryServiceBusApplicationCacheService>();
|
||||
}
|
||||
else
|
||||
{
|
||||
services.AddSingleton<IApplicationCacheService, InMemoryApplicationCacheService>();
|
||||
}
|
||||
|
||||
if(CoreHelpers.SettingHasValue(globalSettings.Mail.SendGridApiKey))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user