feat(api): StatRabbitMqController GetConnectionStats добавлен параметр ThresholdConnections, вынесен в настройки

This commit is contained in:
Mikhail Trubnikov
2024-07-25 14:38:22 +10:00
parent 70d96cb88f
commit 2e82c696aa
4 changed files with 50 additions and 3 deletions

View File

@@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Mvc;
using PARR.API.Contracts.V1;
using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Contracts.V1.Responses.Statistics;
using PARR.API.Controllers.V1.Base;
using PARR.API.Settings;
using PARR.BLL.Services.Interfaces;
@@ -19,13 +20,21 @@ namespace PARR.API.Controllers.V1.Statistics
private readonly MqSettings mqSettings;
private readonly ILogger<StatRabbitMqController> logger;
private readonly IMqAdminService mqAdminService;
private readonly MonitoringSettings monitoringSettings;
public StatRabbitMqController(IMqService mqService, MqSettings mqSettings, ILogger<StatRabbitMqController> logger, IMqAdminService mqAdminService)
public StatRabbitMqController(
IMqService mqService,
MqSettings mqSettings,
ILogger<StatRabbitMqController> logger,
IMqAdminService mqAdminService,
MonitoringSettings monitoringSettings
)
{
this.mqService = mqService;
this.mqSettings = mqSettings;
this.logger = logger;
this.mqAdminService = mqAdminService;
this.monitoringSettings = monitoringSettings;
}
/// <summary>
@@ -42,6 +51,7 @@ namespace PARR.API.Controllers.V1.Statistics
return Ok(new Response<object?>(result.Response, true));
#region comments
//var response = new List<StatRabbitMqQueueResponse>();
//// список очередей
@@ -59,6 +69,7 @@ namespace PARR.API.Controllers.V1.Statistics
//}
//return Ok(new Response<List<StatRabbitMqQueueResponse>>(response.OrderBy(t => t.Name).ToList(), true));
#endregion
}
@@ -74,7 +85,16 @@ namespace PARR.API.Controllers.V1.Statistics
if (!result.IsSuccess)
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = $"Ошибка при получении статистики из RabbitMQ." } }));
return Ok(new Response<object?>(result.Response, true));
var response = new StatRabbitMqConnectionsResponse
{
MqData = result.Response,
MonitoringSettings = new StatRabbitMqConnectionsMonitoringSettings
{
ThresholdConnections = monitoringSettings.RabbitMq?.ThresholdConnections ?? 0
}
};
return Ok(new Response<StatRabbitMqConnectionsResponse>(response, true));
}
}
}