diff --git a/src/ServiceControl.Persistence.InMemory/.editorconfig b/src/ServiceControl.Persistence.InMemory/.editorconfig deleted file mode 100644 index ff993b49bb..0000000000 --- a/src/ServiceControl.Persistence.InMemory/.editorconfig +++ /dev/null @@ -1,4 +0,0 @@ -[*.cs] - -# Justification: ServiceControl app has no synchronization context -dotnet_diagnostic.CA2007.severity = none diff --git a/src/ServiceControl.Persistence.InMemory/InMemoryCustomCheckDataStore.cs b/src/ServiceControl.Persistence.InMemory/InMemoryCustomCheckDataStore.cs deleted file mode 100644 index 4f31cc56e9..0000000000 --- a/src/ServiceControl.Persistence.InMemory/InMemoryCustomCheckDataStore.cs +++ /dev/null @@ -1,69 +0,0 @@ -namespace ServiceControl.Persistence.InMemory -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; - using Contracts.CustomChecks; - using Infrastructure; - using ServiceControl.Persistence; - - class InMemoryCustomCheckDataStore : ICustomChecksDataStore - { - public Task UpdateCustomCheckStatus(CustomCheckDetail detail) - { - var id = detail.GetDeterministicId(); - if (storage.ContainsKey(id)) - { - var storedCheck = storage[id]; - if (storedCheck.HasFailed == detail.HasFailed) - { - return Task.FromResult(CheckStateChange.Unchanged); - } - - storedCheck.HasFailed = detail.HasFailed; - } - else - { - storage.Add(id, detail); - } - - return Task.FromResult(CheckStateChange.Changed); - } - - public Task>> GetStats(PagingInfo paging, string status = null) - { - var result = storage - .Skip(paging.Offset) - .Take(paging.PageSize) - .Select(x => new CustomCheck - { - Category = x.Value.Category, - Status = x.Value.HasFailed ? Status.Fail : Status.Pass, - FailureReason = x.Value.FailureReason, - ReportedAt = x.Value.ReportedAt, - CustomCheckId = x.Value.CustomCheckId, - OriginatingEndpoint = x.Value.OriginatingEndpoint - }) - .ToList(); - - var stats = new QueryStatsInfo("", storage.Count, false); - - return Task.FromResult(new QueryResult>(result, stats)); - } - - public Task DeleteCustomCheck(Guid id) - { - var toRemove = storage.FirstOrDefault(x => x.Key == id); - if (storage.ContainsKey(toRemove.Key)) - { - storage.Remove(toRemove.Key); - } - return Task.CompletedTask; - } - - public Task GetNumberOfFailedChecks() => Task.FromResult(storage.Count(x => x.Value.HasFailed)); - - Dictionary storage = new Dictionary(); - } -} \ No newline at end of file diff --git a/src/ServiceControl.Persistence.InMemory/InMemoryMonitoringDataStore.cs b/src/ServiceControl.Persistence.InMemory/InMemoryMonitoringDataStore.cs deleted file mode 100644 index 26c3459bc1..0000000000 --- a/src/ServiceControl.Persistence.InMemory/InMemoryMonitoringDataStore.cs +++ /dev/null @@ -1,130 +0,0 @@ - -namespace ServiceControl.Persistence.InMemory -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; - using ServiceControl.Operations; - using ServiceControl.Persistence; - - class InMemoryMonitoringDataStore : IMonitoringDataStore - { - List endpoints; - - public InMemoryMonitoringDataStore() - { - endpoints = new List(); - } - - public Task CreateIfNotExists(EndpointDetails endpoint) - { - var id = endpoint.GetDeterministicId(); - - if (endpoints.All(a => a.Id != id)) - { - endpoints.Add(new InMemoryEndpoint - { - Id = id, - HostId = endpoint.HostId, - Host = endpoint.Host, - HostDisplayName = endpoint.Name, - Monitored = false - }); - } - - return Task.CompletedTask; - } - - public Task CreateOrUpdate(EndpointDetails endpoint, IEndpointInstanceMonitoring endpointInstanceMonitoring) - { - var id = endpoint.GetDeterministicId(); - var inMemoryEndpoint = endpoints.FirstOrDefault(a => a.Id == id); - if (inMemoryEndpoint == null) - { - endpoints.Add(new InMemoryEndpoint - { - Id = id, - HostId = endpoint.HostId, - Host = endpoint.Host, - HostDisplayName = endpoint.Name, - Monitored = true - }); - } - else - { - inMemoryEndpoint.Monitored = endpointInstanceMonitoring.IsMonitored(id); - } - - return Task.CompletedTask; - } - - public Task Delete(Guid endpointId) - { - var endpoint = endpoints.FirstOrDefault(e => e.Id == endpointId); - if (endpoint != null) - { - endpoints.Remove(endpoint); - } - - return Task.CompletedTask; - } - - public Task> GetAllKnownEndpoints() - { - var result = endpoints.Select(e => new KnownEndpoint - { - Id = e.Id, - EndpointDetails = new EndpointDetails - { - Host = e.Host, - HostId = e.HostId, - Name = e.HostDisplayName - }, - HostDisplayName = e.HostDisplayName, - Monitored = e.Monitored - }) - .ToList(); - - return Task.FromResult>(result); - } - - public Task UpdateEndpointMonitoring(EndpointDetails endpoint, bool isMonitored) - { - var id = endpoint.GetDeterministicId(); - var inMemoryEndpoint = endpoints.FirstOrDefault(a => a.Id == id); - if (inMemoryEndpoint != null) - { - inMemoryEndpoint.Monitored = isMonitored; - } - - return Task.CompletedTask; - } - - public Task WarmupMonitoringFromPersistence(IEndpointInstanceMonitoring endpointInstanceMonitoring) - { - endpoints?.ForEach(e => - { - endpointInstanceMonitoring.DetectEndpointFromPersistentStore(new EndpointDetails - { - HostId = e.HostId, - Host = e.Host, - Name = e.HostDisplayName - }, e.Monitored); - }); - - return Task.CompletedTask; - } - - public Task Setup() => Task.CompletedTask; - } - - class InMemoryEndpoint - { - public Guid Id { get; set; } - public Guid HostId { get; set; } - public string Host { get; set; } - public string HostDisplayName { get; set; } - public bool Monitored { get; set; } - } -} \ No newline at end of file diff --git a/src/ServiceControl.Persistence.InMemory/InMemoryPersistenceConfiguration.cs b/src/ServiceControl.Persistence.InMemory/InMemoryPersistenceConfiguration.cs deleted file mode 100644 index a30f58f5a4..0000000000 --- a/src/ServiceControl.Persistence.InMemory/InMemoryPersistenceConfiguration.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace ServiceControl.Persistence.InMemory -{ - using System.Collections.Generic; - using Microsoft.Extensions.DependencyInjection; - using ServiceControl.Persistence.UnitOfWork; - - public class InMemoryPersistenceConfiguration : IPersistenceConfiguration - { - public void ConfigureServices(IServiceCollection serviceCollection) - { - serviceCollection.AddSingleton(); - serviceCollection.AddSingleton(); - serviceCollection.AddPartialUnitOfWorkFactory(); - } - - public string Name { get; } - public IEnumerable ConfigurationKeys { get; } - public IPersistence Create(PersistenceSettings settings) => throw new System.NotImplementedException(); - } -} diff --git a/src/ServiceControl.Persistence.InMemory/InMemorySagaAuditDataStore.cs b/src/ServiceControl.Persistence.InMemory/InMemorySagaAuditDataStore.cs deleted file mode 100644 index 17f7421604..0000000000 --- a/src/ServiceControl.Persistence.InMemory/InMemorySagaAuditDataStore.cs +++ /dev/null @@ -1,56 +0,0 @@ -namespace ServiceControl.Persistence.InMemory -{ - using System; - using System.Collections.Concurrent; - using System.Linq; - using System.Threading.Tasks; - using ServiceControl.Persistence.Infrastructure; - using ServiceControl.SagaAudit; - - class InMemorySagaAuditDataStore : ISagaAuditDataStore - { - ConcurrentDictionary snapshotStorage = new ConcurrentDictionary(); - - public Task> GetSagaById(Guid sagaId) - { - var snapshots = snapshotStorage.Values.Where(snapshot => snapshot.SagaId == sagaId); - - var results = from result in snapshots - group result by result.SagaId into g - let first = g.First() - select new SagaHistory - { - Id = first.SagaId, - SagaId = first.SagaId, - SagaType = first.SagaType, - Changes = (from doc in g - select new SagaStateChange - { - Endpoint = doc.Endpoint, - FinishTime = doc.FinishTime, - InitiatingMessage = doc.InitiatingMessage, - OutgoingMessages = doc.OutgoingMessages, - StartTime = doc.StartTime, - StateAfterChange = doc.StateAfterChange, - Status = doc.Status - }) - .OrderByDescending(x => x.FinishTime) - .ToList() - }; - - var sagaHistory = results.FirstOrDefault(); - if (sagaHistory == null) - { - return Task.FromResult(QueryResult.Empty()); - } - - return Task.FromResult(new QueryResult(sagaHistory, new QueryStatsInfo())); - } - - public Task StoreSnapshot(SagaSnapshot sagaSnapshot) - { - snapshotStorage[sagaSnapshot.Id] = sagaSnapshot; - return Task.CompletedTask; - } - } -} diff --git a/src/ServiceControl.Persistence.InMemory/NoOpFailureReclassifier.cs b/src/ServiceControl.Persistence.InMemory/NoOpFailureReclassifier.cs deleted file mode 100644 index 195f55f834..0000000000 --- a/src/ServiceControl.Persistence.InMemory/NoOpFailureReclassifier.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace ServiceControl.Persistence.InMemory -{ - using System.Threading.Tasks; - - class NoOpFailureReclassifier : IReclassifyFailedMessages - { - public Task ReclassifyFailedMessages(bool force) => Task.FromResult(0); - } -} diff --git a/src/ServiceControl.Persistence.InMemory/ServiceControl.Persistence.InMemory.csproj b/src/ServiceControl.Persistence.InMemory/ServiceControl.Persistence.InMemory.csproj deleted file mode 100644 index be9d9f606f..0000000000 --- a/src/ServiceControl.Persistence.InMemory/ServiceControl.Persistence.InMemory.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - net472 - - - - - - - - - - - \ No newline at end of file diff --git a/src/ServiceControl.Persistence.InMemory/UnitOfWork/InMemoryIngestionUnitOfWork.cs b/src/ServiceControl.Persistence.InMemory/UnitOfWork/InMemoryIngestionUnitOfWork.cs deleted file mode 100644 index 432db928bb..0000000000 --- a/src/ServiceControl.Persistence.InMemory/UnitOfWork/InMemoryIngestionUnitOfWork.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace ServiceControl.Persistence.InMemory -{ - using System.Collections.Concurrent; - using System.Threading.Tasks; - using ServiceControl.Persistence.UnitOfWork; - - class InMemoryIngestionUnitOfWork : IngestionUnitOfWorkBase - { - ConcurrentBag knownEndpoints = new ConcurrentBag(); - IMonitoringDataStore dataStore; - - public InMemoryIngestionUnitOfWork(IMonitoringDataStore dataStore) - { - this.dataStore = dataStore; - Monitoring = new InMemoryMonitoringIngestionUnitOfWork(this); - } - - public override async Task Complete() - { - foreach (var endpoint in knownEndpoints) - { - await dataStore.CreateIfNotExists(endpoint.EndpointDetails); - } - } - - internal void AddEndpoint(KnownEndpoint knownEndpoint) => knownEndpoints.Add(knownEndpoint); - } -} \ No newline at end of file diff --git a/src/ServiceControl.Persistence.InMemory/UnitOfWork/InMemoryIngestionUnitOfWorkFactory.cs b/src/ServiceControl.Persistence.InMemory/UnitOfWork/InMemoryIngestionUnitOfWorkFactory.cs deleted file mode 100644 index 31ca7ba00f..0000000000 --- a/src/ServiceControl.Persistence.InMemory/UnitOfWork/InMemoryIngestionUnitOfWorkFactory.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace ServiceControl.Persistence.InMemory -{ - using System.Threading.Tasks; - using ServiceControl.Persistence.UnitOfWork; - - class InMemoryIngestionUnitOfWorkFactory : IIngestionUnitOfWorkFactory - { - IMonitoringDataStore dataStore; - - public InMemoryIngestionUnitOfWorkFactory(IMonitoringDataStore dataStore) => this.dataStore = dataStore; - - public ValueTask StartNew() - => new ValueTask(new InMemoryIngestionUnitOfWork(dataStore)); - - public bool CanIngestMore() => true; - } -} \ No newline at end of file diff --git a/src/ServiceControl.Persistence.InMemory/UnitOfWork/InMemoryMonitoringIngestionUnitOfWork.cs b/src/ServiceControl.Persistence.InMemory/UnitOfWork/InMemoryMonitoringIngestionUnitOfWork.cs deleted file mode 100644 index 0395ff916f..0000000000 --- a/src/ServiceControl.Persistence.InMemory/UnitOfWork/InMemoryMonitoringIngestionUnitOfWork.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace ServiceControl.Persistence.InMemory -{ - using System.Threading.Tasks; - using ServiceControl.Persistence.UnitOfWork; - - class InMemoryMonitoringIngestionUnitOfWork : IMonitoringIngestionUnitOfWork - { - readonly InMemoryIngestionUnitOfWork parentUnitOfWork; - - public InMemoryMonitoringIngestionUnitOfWork(InMemoryIngestionUnitOfWork parentUnitOfWork) - => this.parentUnitOfWork = parentUnitOfWork; - - public Task RecordKnownEndpoint(KnownEndpoint knownEndpoint) - { - parentUnitOfWork.AddEndpoint(knownEndpoint); - return Task.CompletedTask; - } - } -} \ No newline at end of file diff --git a/src/ServiceControl.sln b/src/ServiceControl.sln index d580a47f88..dfae66114e 100644 --- a/src/ServiceControl.sln +++ b/src/ServiceControl.sln @@ -111,8 +111,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Testing", "Testing", "{927A EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Persistence", "Persistence", "{9B52418E-BF18-4D25-BE17-4B56D3FB1154}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceControl.Persistence.InMemory", "ServiceControl.Persistence.InMemory\ServiceControl.Persistence.InMemory.csproj", "{C536A96A-D4B7-4793-890E-5A29ED7144E5}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceControl.Persistence.RavenDb", "ServiceControl.Persistence.RavenDb\ServiceControl.Persistence.RavenDb.csproj", "{07F15F50-0A81-4872-9C7D-34DE88599B9F}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Persistence", "Persistence", "{BD162BC6-705F-45B4-A6B5-C138DC966C1D}" @@ -623,18 +621,6 @@ Global {56422C80-6A26-46B4-AF5C-84AF08BAB1D1}.Release|x64.Build.0 = Release|Any CPU {56422C80-6A26-46B4-AF5C-84AF08BAB1D1}.Release|x86.ActiveCfg = Release|Any CPU {56422C80-6A26-46B4-AF5C-84AF08BAB1D1}.Release|x86.Build.0 = Release|Any CPU - {C536A96A-D4B7-4793-890E-5A29ED7144E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C536A96A-D4B7-4793-890E-5A29ED7144E5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C536A96A-D4B7-4793-890E-5A29ED7144E5}.Debug|x64.ActiveCfg = Debug|Any CPU - {C536A96A-D4B7-4793-890E-5A29ED7144E5}.Debug|x64.Build.0 = Debug|Any CPU - {C536A96A-D4B7-4793-890E-5A29ED7144E5}.Debug|x86.ActiveCfg = Debug|Any CPU - {C536A96A-D4B7-4793-890E-5A29ED7144E5}.Debug|x86.Build.0 = Debug|Any CPU - {C536A96A-D4B7-4793-890E-5A29ED7144E5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C536A96A-D4B7-4793-890E-5A29ED7144E5}.Release|Any CPU.Build.0 = Release|Any CPU - {C536A96A-D4B7-4793-890E-5A29ED7144E5}.Release|x64.ActiveCfg = Release|Any CPU - {C536A96A-D4B7-4793-890E-5A29ED7144E5}.Release|x64.Build.0 = Release|Any CPU - {C536A96A-D4B7-4793-890E-5A29ED7144E5}.Release|x86.ActiveCfg = Release|Any CPU - {C536A96A-D4B7-4793-890E-5A29ED7144E5}.Release|x86.Build.0 = Release|Any CPU {07F15F50-0A81-4872-9C7D-34DE88599B9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {07F15F50-0A81-4872-9C7D-34DE88599B9F}.Debug|Any CPU.Build.0 = Debug|Any CPU {07F15F50-0A81-4872-9C7D-34DE88599B9F}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -1078,7 +1064,6 @@ Global {76C0AC5A-E7CD-4E6B-88DC-B473C4C25295} = {9AF9D3C7-E859-451B-BA4D-B954D289213A} {927A078A-E271-4878-A153-86D71AE510E2} = {55C388DD-2B39-4C2F-AEBD-AFD3444815F1} {9B52418E-BF18-4D25-BE17-4B56D3FB1154} = {CD6E567B-C17B-4C90-87CA-F6CB941EC307} - {C536A96A-D4B7-4793-890E-5A29ED7144E5} = {9B52418E-BF18-4D25-BE17-4B56D3FB1154} {07F15F50-0A81-4872-9C7D-34DE88599B9F} = {9B52418E-BF18-4D25-BE17-4B56D3FB1154} {BD162BC6-705F-45B4-A6B5-C138DC966C1D} = {E2249BAA-D9E9-4369-9C70-0E21C69A3E56} {59B2735E-9B70-4277-8E8C-C8CCB40A097A} = {BD162BC6-705F-45B4-A6B5-C138DC966C1D}