1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-03 00:52:49 -05:00

write events to table storage

This commit is contained in:
Kyle Spearrin
2017-12-08 16:03:20 -05:00
parent 8626d7e769
commit 83a7c98fae
5 changed files with 78 additions and 15 deletions

View File

@ -12,8 +12,12 @@ namespace Bit.Core.Repositories.TableStorage
public class EventRepository : IEventRepository
{
public EventRepository(GlobalSettings globalSettings)
: this(globalSettings.Storage.ConnectionString)
{ }
public EventRepository(string storageConnectionString)
{
var storageAccount = CloudStorageAccount.Parse(globalSettings.Storage.ConnectionString);
var storageAccount = CloudStorageAccount.Parse(storageConnectionString);
var tableClient = storageAccount.CreateCloudTableClient();
Table = tableClient.GetTableReference("event");
}

View File

@ -8,14 +8,11 @@ namespace Bit.Core.Services
public class RepositoryEventWriteService : IEventWriteService
{
private readonly IEventRepository _eventRepository;
private readonly GlobalSettings _globalSettings;
public RepositoryEventWriteService(
IEventRepository eventRepository,
GlobalSettings globalSettings)
IEventRepository eventRepository)
{
_eventRepository = eventRepository;
_globalSettings = globalSettings;
}
public async Task CreateAsync(EventTableEntity entity)

View File

@ -20,8 +20,8 @@ using Microsoft.WindowsAzure.Storage;
using System;
using System.IO;
using SqlServerRepos = Bit.Core.Repositories.SqlServer;
using TableStorageRepos = Bit.Core.Repositories.TableStorage;
using System.Threading.Tasks;
using TableStorageRepos = Bit.Core.Repositories.TableStorage;
namespace Bit.Core.Utilities
{
@ -44,7 +44,7 @@ namespace Bit.Core.Utilities
if(globalSettings.SelfHosted)
{
// TODO: Sql server repo
// TODO: Sql server event repo
}
else
{
@ -59,7 +59,7 @@ namespace Bit.Core.Utilities
services.AddScoped<IOrganizationService, OrganizationService>();
services.AddScoped<ICollectionService, CollectionService>();
services.AddScoped<IGroupService, GroupService>();
services.AddScoped<Services.IEventService, NoopEventService>();
services.AddScoped<Services.IEventService, EventService>();
services.AddSingleton<IDeviceService, DeviceService>();
}
@ -105,15 +105,24 @@ namespace Bit.Core.Utilities
if(!globalSettings.SelfHosted && CoreHelpers.SettingHasValue(globalSettings.Storage.ConnectionString))
{
services.AddSingleton<IBlockIpService, AzureQueueBlockIpService>();
//services.AddSingleton<IEventWriteService, AzureQueueEventWriteService>();
}
else
{
services.AddSingleton<IBlockIpService, NoopBlockIpService>();
//services.AddSingleton<IEventWriteService, RepositoryEventWriteService>();
}
services.AddSingleton<IEventWriteService, NoopEventWriteService>();
if(!globalSettings.SelfHosted && CoreHelpers.SettingHasValue(globalSettings.Storage.ConnectionString))
{
services.AddSingleton<IEventWriteService, AzureQueueEventWriteService>();
}
else if(globalSettings.SelfHosted)
{
services.AddSingleton<IEventWriteService, RepositoryEventWriteService>();
}
else
{
services.AddSingleton<IEventWriteService, NoopEventWriteService>();
}
if(CoreHelpers.SettingHasValue(globalSettings.Attachment.ConnectionString))
{