mirror of
https://github.com/bitwarden/server
synced 2026-01-20 01:13:18 +00:00
Refactor configuration for azure queue service for events to include queue name (#6724)
* Refactor configuration for azure queue service for events to include queue name * Address PR feedback * Add check for queue name before writing to Azure Queue Service * Fix file encoding (lint error)
This commit is contained in:
@@ -91,7 +91,8 @@ public static class EventIntegrationsServiceCollectionExtensions
|
||||
return services;
|
||||
}
|
||||
|
||||
if (CoreHelpers.SettingHasValue(globalSettings.Events.ConnectionString))
|
||||
if (CoreHelpers.SettingHasValue(globalSettings.Events.ConnectionString) &&
|
||||
CoreHelpers.SettingHasValue(globalSettings.Events.QueueName))
|
||||
{
|
||||
services.TryAddSingleton<IEventWriteService, AzureQueueEventWriteService>();
|
||||
return services;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Bit.Core.Services;
|
||||
public class AzureQueueEventWriteService : AzureQueueService<IEvent>, IEventWriteService
|
||||
{
|
||||
public AzureQueueEventWriteService(GlobalSettings globalSettings) : base(
|
||||
new QueueClient(globalSettings.Events.ConnectionString, "event"),
|
||||
new QueueClient(globalSettings.Events.ConnectionString, globalSettings.Events.QueueName),
|
||||
JsonHelpers.IgnoreWritingNull)
|
||||
{ }
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public class GlobalSettings : IGlobalSettings
|
||||
public virtual EventLoggingSettings EventLogging { get; set; } = new EventLoggingSettings();
|
||||
public virtual MailSettings Mail { get; set; } = new MailSettings();
|
||||
public virtual IConnectionStringSettings Storage { get; set; } = new ConnectionStringSettings();
|
||||
public virtual ConnectionStringSettings Events { get; set; } = new ConnectionStringSettings();
|
||||
public virtual AzureQueueEventSettings Events { get; set; } = new AzureQueueEventSettings();
|
||||
public virtual DistributedCacheSettings DistributedCache { get; set; } = new DistributedCacheSettings();
|
||||
public virtual NotificationsSettings Notifications { get; set; } = new NotificationsSettings();
|
||||
public virtual IFileStorageSettings Attachment { get; set; }
|
||||
@@ -395,6 +395,24 @@ public class GlobalSettings : IGlobalSettings
|
||||
}
|
||||
}
|
||||
|
||||
public class AzureQueueEventSettings : IConnectionStringSettings
|
||||
{
|
||||
private string _connectionString;
|
||||
private string _queueName;
|
||||
|
||||
public string ConnectionString
|
||||
{
|
||||
get => _connectionString;
|
||||
set => _connectionString = value?.Trim('"');
|
||||
}
|
||||
|
||||
public string QueueName
|
||||
{
|
||||
get => _queueName;
|
||||
set => _queueName = value?.Trim('"');
|
||||
}
|
||||
}
|
||||
|
||||
public class ConnectionStringSettings : IConnectionStringSettings
|
||||
{
|
||||
private string _connectionString;
|
||||
|
||||
Reference in New Issue
Block a user