1
0
mirror of https://github.com/bitwarden/server synced 2026-02-21 11:53:42 +00:00

[PM-23845] Update cache service to handle concurrency (#6170)

This commit is contained in:
Jimmy Vo
2025-09-12 13:44:19 -04:00
committed by GitHub
parent 4e64d35f89
commit 854abb0993
15 changed files with 1392 additions and 10 deletions

View File

@@ -0,0 +1,63 @@
using Azure.Messaging.ServiceBus;
using Bit.Core.AdminConsole.Entities;
using Bit.Core.Enums;
using Bit.Core.Settings;
using Bit.Core.Utilities;
namespace Bit.Core.AdminConsole.AbilitiesCache;
public class ServiceBusApplicationCacheMessaging : IApplicationCacheServiceBusMessaging
{
private readonly ServiceBusSender _topicMessageSender;
private readonly string _subName;
public ServiceBusApplicationCacheMessaging(
GlobalSettings globalSettings)
{
_subName = CoreHelpers.GetApplicationCacheServiceBusSubscriptionName(globalSettings);
var serviceBusClient = new ServiceBusClient(globalSettings.ServiceBus.ConnectionString);
_topicMessageSender = serviceBusClient.CreateSender(globalSettings.ServiceBus.ApplicationCacheTopicName);
}
public async Task NotifyOrganizationAbilityUpsertedAsync(Organization organization)
{
var message = new ServiceBusMessage
{
Subject = _subName,
ApplicationProperties =
{
{ "type", (byte)ApplicationCacheMessageType.UpsertOrganizationAbility },
{ "id", organization.Id },
}
};
await _topicMessageSender.SendMessageAsync(message);
}
public async Task NotifyOrganizationAbilityDeletedAsync(Guid organizationId)
{
var message = new ServiceBusMessage
{
Subject = _subName,
ApplicationProperties =
{
{ "type", (byte)ApplicationCacheMessageType.DeleteOrganizationAbility },
{ "id", organizationId },
}
};
await _topicMessageSender.SendMessageAsync(message);
}
public async Task NotifyProviderAbilityDeletedAsync(Guid providerId)
{
var message = new ServiceBusMessage
{
Subject = _subName,
ApplicationProperties =
{
{ "type", (byte)ApplicationCacheMessageType.DeleteProviderAbility },
{ "id", providerId },
}
};
await _topicMessageSender.SendMessageAsync(message);
}
}