Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@
using ServiceControl.Audit.Auditing.BodyStorage;
using ServiceControl.Audit.Auditing.MessagesView;
using ServiceControl.Audit.Infrastructure;
using ServiceControl.Audit.Monitoring;
using ServiceControl.Audit.Persistence.Infrastructure;
using ServiceControl.Audit.Persistence.Monitoring;
using ServiceControl.SagaAudit;

class InMemoryAuditDataStore : IAuditDataStore
{
IBodyStorage bodyStorage;
public List<KnownEndpoint> knownEndpoints;
public List<FailedAuditImport> failedAuditImports;

public InMemoryAuditDataStore(IBodyStorage bodyStorage)
Expand All @@ -26,7 +22,6 @@ public InMemoryAuditDataStore(IBodyStorage bodyStorage)
sagaHistories = [];
messageViews = [];
processedMessages = [];
knownEndpoints = [];
failedAuditImports = [];
}

Expand Down Expand Up @@ -176,25 +171,6 @@ Task<MessageBodyView> GetMessageBodyFromMetadata(string messageId)
return Task.FromResult(MessageBodyView.FromString(body, contentType, bodySize, string.Empty));
}

public async Task<QueryResult<IList<KnownEndpointsView>>> QueryKnownEndpoints(CancellationToken cancellationToken)
{
var knownEndpointsView = knownEndpoints
.Select(x => new KnownEndpointsView
{
Id = DeterministicGuid.MakeId(x.Name, x.HostId.ToString()),
EndpointDetails = new EndpointDetails
{
Host = x.Host,
HostId = x.HostId,
Name = x.Name
},
HostDisplayName = x.Host
})
.ToList();

return await Task.FromResult(new QueryResult<IList<KnownEndpointsView>>(knownEndpointsView, new QueryStatsInfo(string.Empty, knownEndpointsView.Count)));
}

public Task<QueryResult<IList<AuditCount>>> QueryAuditCounts(string endpointName, CancellationToken cancellationToken)
{
var results = messageViews
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Threading.Tasks;
using Auditing.BodyStorage;
using ServiceControl.Audit.Auditing;
using ServiceControl.Audit.Persistence.Monitoring;
using ServiceControl.Audit.Persistence.UnitOfWork;
using ServiceControl.SagaAudit;

Expand All @@ -16,12 +15,6 @@ class InMemoryAuditIngestionUnitOfWork(
{
public ValueTask DisposeAsync() => ValueTask.CompletedTask;

public Task RecordKnownEndpoint(KnownEndpoint knownEndpoint, CancellationToken cancellationToken)
{
dataStore.knownEndpoints.Add(knownEndpoint);
return Task.CompletedTask;
}

public async Task RecordProcessedMessage(ProcessedMessage processedMessage, ReadOnlyMemory<byte> body, CancellationToken cancellationToken)
{
if (!body.IsEmpty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@
using Auditing.MessagesView;
using Extensions;
using Indexes;
using Monitoring;
using Raven.Client.Documents;
using ServiceControl.Audit.Auditing;
using ServiceControl.Audit.Infrastructure;
using ServiceControl.Audit.Monitoring;
using ServiceControl.Audit.Persistence.Infrastructure;
using ServiceControl.SagaAudit;
using Transformers;

Expand Down Expand Up @@ -125,27 +122,6 @@ public async Task<MessageBodyView> GetMessageBody(string messageId, Cancellation
);
}

public async Task<QueryResult<IList<KnownEndpointsView>>> QueryKnownEndpoints(CancellationToken cancellationToken)
{
using var session = await sessionProvider.OpenSession(cancellationToken: cancellationToken);
var endpoints = await session.Advanced.LoadStartingWithAsync<KnownEndpoint>(KnownEndpoint.CollectionName, pageSize: 1024, token: cancellationToken);

var knownEndpoints = endpoints
.Select(x => new KnownEndpointsView
{
Id = DeterministicGuid.MakeId(x.Name, x.HostId.ToString()),
EndpointDetails = new EndpointDetails
{
Host = x.Host,
HostId = x.HostId,
Name = x.Name
},
HostDisplayName = x.Host
})
.ToList();

return new QueryResult<IList<KnownEndpointsView>>(knownEndpoints, new QueryStatsInfo(string.Empty, knownEndpoints.Count));
}

public async Task<QueryResult<IList<AuditCount>>> QueryAuditCounts(string endpointName, CancellationToken cancellationToken)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Threading.Tasks;
using Auditing;
using Auditing.BodyStorage;
using Monitoring;
using NServiceBus;
using Persistence.UnitOfWork;
using Raven.Client;
Expand Down Expand Up @@ -50,9 +49,6 @@ MetadataAsDictionary GetExpirationMetadata() =>
public Task RecordSagaSnapshot(SagaSnapshot sagaSnapshot, CancellationToken cancellationToken)
=> bulkInsert.StoreAsync(sagaSnapshot, GetExpirationMetadata());

public Task RecordKnownEndpoint(KnownEndpoint knownEndpoint, CancellationToken cancellationToken)
=> bulkInsert.StoreAsync(knownEndpoint, GetExpirationMetadata());

public async ValueTask DisposeAsync()
{
await bulkInsert.DisposeAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Threading.Tasks;
using NUnit.Framework;
using ServiceControl.Audit.Infrastructure;
using ServiceControl.Audit.Persistence.RavenDB;
using TestHelper;

Expand Down Expand Up @@ -35,7 +36,7 @@ public override async Task Setup()
[Test]
public async Task Verify_embedded_database()
{
await DataStore.QueryKnownEndpoints(TestContext.CurrentContext.CancellationToken);
await DataStore.GetMessages(false, new PagingInfo(), new SortInfo("Id", "asc"), cancellationToken: TestContext.CurrentContext.CancellationToken);

using (Assert.EnterMultipleScope())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Auditing;
using Monitoring;
using NServiceBus;
using NUnit.Framework;
using SagaAudit;
Expand Down Expand Up @@ -44,36 +43,6 @@ public async Task AuditMessageRetention()
}
}

[Test]
public async Task KnownEndpointRetention()
{
var knownEndpoint = new KnownEndpoint()
{
Host = "Myself",
HostId = Guid.NewGuid(),
Id = "KnownEndpoints/1234123",
LastSeen = DateTime.UtcNow,
Name = "Wazowsky"
};

await IngestKnownEndpoints(
knownEndpoint
);

var queryResultBeforeExpiration = await DataStore.QueryKnownEndpoints(TestContext.CurrentContext.CancellationToken);

await Task.Delay(4000);

var queryResultAfterExpiration = await DataStore.QueryKnownEndpoints(TestContext.CurrentContext.CancellationToken);

Assert.That(queryResultBeforeExpiration.Results, Has.Count.EqualTo(1));
using (Assert.EnterMultipleScope())
{
Assert.That(queryResultBeforeExpiration.Results[0].EndpointDetails.Name, Is.EqualTo("Wazowsky"));
Assert.That(queryResultAfterExpiration.Results.Count, Is.EqualTo(0));
}
}

[Test]
public async Task SagaSnapshotRetention()
{
Expand Down Expand Up @@ -147,17 +116,6 @@ async Task IngestProcessedMessagesAudits(params ProcessedMessage[] processedMess
await configuration.CompleteDBOperation();
}

async Task IngestKnownEndpoints(params KnownEndpoint[] knownEndpoints)
{
var unitOfWork = await StartAuditUnitOfWork(knownEndpoints.Length);
foreach (var knownEndpoint in knownEndpoints)
{
await unitOfWork.RecordKnownEndpoint(knownEndpoint);
}
await unitOfWork.DisposeAsync();
await configuration.CompleteDBOperation();
}

async Task IngestSagaAudits(params SagaSnapshot[] snapshots)
{
var unitOfWork = await StartAuditUnitOfWork(snapshots.Length);
Expand Down
72 changes: 0 additions & 72 deletions src/ServiceControl.Audit.Persistence.Tests/KnownEndpointsTests.cs

This file was deleted.

1 change: 0 additions & 1 deletion src/ServiceControl.Audit.Persistence/IAuditDataStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

public interface IAuditDataStore
{
Task<QueryResult<IList<KnownEndpointsView>>> QueryKnownEndpoints(CancellationToken cancellationToken);
Task<QueryResult<SagaHistory>> QuerySagaHistoryById(Guid input, CancellationToken cancellationToken);
Task<QueryResult<IList<MessagesView>>> GetMessages(bool includeSystemMessages, PagingInfo pagingInfo, SortInfo sortInfo, DateTimeRange timeSentRange = null, CancellationToken cancellationToken = default);
Task<QueryResult<IList<MessagesView>>> QueryMessages(string searchParam, PagingInfo pagingInfo, SortInfo sortInfo, DateTimeRange timeSentRange = null, CancellationToken cancellationToken = default);
Expand Down
25 changes: 0 additions & 25 deletions src/ServiceControl.Audit.Persistence/Monitoring/KnownEndpoint.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
using System.Threading;
using System.Threading.Tasks;
using Auditing;
using Monitoring;
using ServiceControl.SagaAudit;

public interface IAuditIngestionUnitOfWork : IAsyncDisposable
{
Task RecordProcessedMessage(ProcessedMessage processedMessage, ReadOnlyMemory<byte> body = default, CancellationToken cancellationToken = default);
Task RecordSagaSnapshot(SagaSnapshot sagaSnapshot, CancellationToken cancellationToken = default);
Task RecordKnownEndpoint(KnownEndpoint knownEndpoint, CancellationToken cancellationToken = default);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ GET /endpoints/{endpoint}/audit-count => ServiceControl.Audit.Auditing.MessagesV
GET /endpoints/{endpoint}/messages => ServiceControl.Audit.Auditing.MessagesView.GetMessagesController:GetEndpointMessages(PagingInfo pagingInfo, SortInfo sortInfo, Boolean includeSystemMessages, String endpoint, CancellationToken cancellationToken)
GET /endpoints/{endpoint}/messages/search => ServiceControl.Audit.Auditing.MessagesView.GetMessagesController:Search(PagingInfo pagingInfo, SortInfo sortInfo, String endpoint, String q, CancellationToken cancellationToken)
GET /endpoints/{endpoint}/messages/search/{keyword} => ServiceControl.Audit.Auditing.MessagesView.GetMessagesController:SearchByKeyword(PagingInfo pagingInfo, SortInfo sortInfo, String endpoint, String keyword, CancellationToken cancellationToken)
GET /endpoints/known => ServiceControl.Audit.Monitoring.KnownEndpointsController:GetAll(PagingInfo pagingInfo, CancellationToken cancellationToken)
GET /endpoints/known => ServiceControl.Audit.Monitoring.KnownEndpointsController:GetAll(PagingInfo pagingInfo)
GET /instance-info => ServiceControl.Audit.Infrastructure.WebApi.RootController:Config()
GET /messages => ServiceControl.Audit.Auditing.MessagesView.GetMessagesController:GetAllMessages(PagingInfo pagingInfo, SortInfo sortInfo, Boolean includeSystemMessages, CancellationToken cancellationToken)
GET /messages/{id}/body => ServiceControl.Audit.Auditing.MessagesView.GetMessagesController:Get(String id, CancellationToken cancellationToken)
Expand Down
Loading