mirror of
https://github.com/bitwarden/server
synced 2026-01-04 17:43:53 +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:
@@ -6,6 +6,7 @@ using Azure.Storage.Queues;
|
||||
using Bit.Core;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Services;
|
||||
using Bit.Core.Settings;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.EventsProcessor;
|
||||
@@ -13,7 +14,7 @@ namespace Bit.EventsProcessor;
|
||||
public class AzureQueueHostedService : IHostedService, IDisposable
|
||||
{
|
||||
private readonly ILogger<AzureQueueHostedService> _logger;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly GlobalSettings _globalSettings;
|
||||
|
||||
private Task _executingTask;
|
||||
private CancellationTokenSource _cts;
|
||||
@@ -22,10 +23,10 @@ public class AzureQueueHostedService : IHostedService, IDisposable
|
||||
|
||||
public AzureQueueHostedService(
|
||||
ILogger<AzureQueueHostedService> logger,
|
||||
IConfiguration configuration)
|
||||
GlobalSettings globalSettings)
|
||||
{
|
||||
_logger = logger;
|
||||
_configuration = configuration;
|
||||
_globalSettings = globalSettings;
|
||||
}
|
||||
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
@@ -56,11 +57,12 @@ public class AzureQueueHostedService : IHostedService, IDisposable
|
||||
|
||||
private async Task ExecuteAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var storageConnectionString = _configuration["azureStorageConnectionString"];
|
||||
var queueName = _configuration["azureQueueServiceQueueName"];
|
||||
var storageConnectionString = _globalSettings.Events.ConnectionString;
|
||||
var queueName = _globalSettings.Events.QueueName;
|
||||
if (string.IsNullOrWhiteSpace(storageConnectionString) ||
|
||||
string.IsNullOrWhiteSpace(queueName))
|
||||
{
|
||||
_logger.LogInformation("Azure Queue Hosted Service is disabled. Missing connection string or queue name.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user