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 @@ -240,47 +240,6 @@ await Define<QueueSearchContext>()
Assert.That(searchResults.Count, Is.EqualTo(1), "Result count did not match");
}

[Test]
public async Task Should_only_return_queueaddresses_that_startswith_search()
{
var searchResults = new List<QueueAddress>();
const string searchTerm = "another";
const string searchEndpointName = "AnotherFailingEndpoint";

await Define<QueueSearchContext>()
.WithEndpoint<FailingEndpoint>(b =>
{
b.DoNotFailOnErrorMessages();
b.When(bus => bus.SendLocal(new MyMessage()));
})
.WithEndpoint<FailingEndpoint>(b =>
{
b.DoNotFailOnErrorMessages();
b.CustomConfig(configuration => configuration.GetSettings().Set("NServiceBus.Routing.EndpointName", searchEndpointName));
b.When(bus => bus.SendLocal(new MyMessage()));
})
.WithEndpoint<FailingEndpoint>(b =>
{
b.DoNotFailOnErrorMessages();
b.CustomConfig(configuration => configuration.GetSettings().Set("NServiceBus.Routing.EndpointName", "YetAnotherEndpoint"));
b.When(bus => bus.SendLocal(new MyMessage()));
}).Done(async c =>
{
if (c.FailedMessageCount < 3)
{
return false;
}

var result = await this.TryGetMany<QueueAddress>($"/api/errors/queues/addresses/search/{searchTerm}");
searchResults = result;
return result;
})
.Run();

Assert.That(searchResults.Count, Is.EqualTo(1), "Result count did not match");
Assert.That(searchResults[0].PhysicalAddress.StartsWith(searchEndpointName, StringComparison.InvariantCultureIgnoreCase), Is.True);
}

public class EndpointThatUsesSignalR : EndpointConfigurationBuilder
{
public EndpointThatUsesSignalR() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,4 @@ public class QueueAddressStore : IQueueAddressStore
{
public Task<QueryResult<IList<QueueAddress>>> GetAddresses(PagingInfo pagingInfo) =>
throw new NotImplementedException();

public Task<QueryResult<IList<QueueAddress>>> GetAddressesBySearchTerm(string search, PagingInfo pagingInfo) =>
throw new NotImplementedException();
}
15 changes: 0 additions & 15 deletions src/ServiceControl.Persistence.RavenDB/QueueAddressStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,5 @@ public async Task<QueryResult<IList<QueueAddress>>> GetAddresses(PagingInfo pagi
var result = new QueryResult<IList<QueueAddress>>(addresses, stats.ToQueryStatsInfo());
return result;
}

public async Task<QueryResult<IList<QueueAddress>>> GetAddressesBySearchTerm(string search, PagingInfo pagingInfo)
{
using var session = await sessionProvider.OpenSession();
var failedMessageQueues = await session
.Query<QueueAddress, QueueAddressIndex>()
.Statistics(out var stats)
.Paging(pagingInfo)
.Where(q => q.PhysicalAddress.StartsWith(search))
.OrderBy(q => q.PhysicalAddress)
.ToListAsync();

var result = new QueryResult<IList<QueueAddress>>(failedMessageQueues, stats.ToQueryStatsInfo());
return result;
}
}
}
1 change: 0 additions & 1 deletion src/ServiceControl.Persistence/IQueueAddressStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
public interface IQueueAddressStore
{
Task<QueryResult<IList<QueueAddress>>> GetAddresses(PagingInfo pagingInfo);
Task<QueryResult<IList<QueueAddress>>> GetAddressesBySearchTerm(string search, PagingInfo pagingInfo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ GET /errors/groups/{classifier?} => ServiceControl.MessageFailures.Api.ArchiveMe
GET /errors/last/{failedMessageId:required:minlength(1)} => ServiceControl.MessageFailures.Api.GetErrorByIdController:ErrorLastBy(String failedMessageId)
POST /errors/queues/{queueAddress:required:minlength(1)}/retry => ServiceControl.MessageFailures.Api.RetryMessagesController:RetryAllBy(String queueAddress)
GET /errors/queues/addresses => ServiceControl.MessageFailures.Api.QueueAddressController:GetAddresses(PagingInfo pagingInfo)
GET /errors/queues/addresses/search/{search} => ServiceControl.MessageFailures.Api.QueueAddressController:GetAddressesBySearchTerm(PagingInfo pagingInfo, String search)
POST /errors/retry => ServiceControl.MessageFailures.Api.RetryMessagesController:RetryAllBy(List<String> messageIds)
POST /errors/retry/all => ServiceControl.MessageFailures.Api.RetryMessagesController:RetryAll()
GET /errors/summary => ServiceControl.MessageFailures.Api.GetAllErrorsController:ErrorsSummary()
Expand Down
60 changes: 21 additions & 39 deletions src/ServiceControl/MessageFailures/Api/QueueAddressController.cs
Original file line number Diff line number Diff line change
@@ -1,45 +1,27 @@
namespace ServiceControl.MessageFailures.Api
{
using System.Collections.Generic;
using System.Threading.Tasks;
using Infrastructure.Auth;
using Infrastructure.WebApi;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Persistence.Infrastructure;
using ServiceControl.Persistence;

[ApiController]
[Route("api")]
public class QueueAddressController(IQueueAddressStore store) : ControllerBase
{
[Authorize(Policy = Permissions.ErrorQueuesView)]
[Route("errors/queues/addresses")]
[HttpGet]
public async Task<IList<QueueAddress>> GetAddresses([FromQuery] PagingInfo pagingInfo)
{
var result = await store.GetAddresses(pagingInfo);

Response.WithQueryStatsAndPagingInfo(result.QueryStats, pagingInfo);
namespace ServiceControl.MessageFailures.Api;

return result.Results;
}
using System.Collections.Generic;
using System.Threading.Tasks;
using Infrastructure.Auth;
using Infrastructure.WebApi;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Persistence.Infrastructure;
using ServiceControl.Persistence;

[Authorize(Policy = Permissions.ErrorQueuesView)]
[Route("errors/queues/addresses/search/{search}")]
[HttpGet]
public async Task<ActionResult<IList<QueueAddress>>> GetAddressesBySearchTerm([FromQuery] PagingInfo pagingInfo, string search = null)
{
if (string.IsNullOrWhiteSpace(search))
{
return BadRequest();
}

var result = await store.GetAddressesBySearchTerm(search, pagingInfo);
[ApiController]
[Route("api")]
public class QueueAddressController(IQueueAddressStore store) : ControllerBase
{
[Authorize(Policy = Permissions.ErrorQueuesView)]
[Route("errors/queues/addresses")]
[HttpGet]
public async Task<IList<QueueAddress>> GetAddresses([FromQuery] PagingInfo pagingInfo)
{
var result = await store.GetAddresses(pagingInfo);

Response.WithQueryStatsAndPagingInfo(result.QueryStats, pagingInfo);
Response.WithQueryStatsAndPagingInfo(result.QueryStats, pagingInfo);

return Ok(result.Results);
}
return result.Results;
}
}