diff --git a/CleanArchitecture.Api/Extensions/ConfigurationExtensions.cs b/CleanArchitecture.Api/Extensions/ConfigurationExtensions.cs index bbe88c7..a539f68 100644 --- a/CleanArchitecture.Api/Extensions/ConfigurationExtensions.cs +++ b/CleanArchitecture.Api/Extensions/ConfigurationExtensions.cs @@ -35,7 +35,7 @@ public static RabbitMqConfiguration GetRabbitMqConfiguration( Port = int.Parse(rabbitPort ?? "0"), Enabled = bool.Parse(rabbitEnabled ?? "false"), Username = rabbitUser ?? "", - Password = rabbitPass ?? "", + Password = rabbitPass ?? "" }; } } \ No newline at end of file diff --git a/CleanArchitecture.Api/Program.cs b/CleanArchitecture.Api/Program.cs index e0410b8..37a2c17 100644 --- a/CleanArchitecture.Api/Program.cs +++ b/CleanArchitecture.Api/Program.cs @@ -33,8 +33,11 @@ var isAspire = builder.Configuration["ASPIRE_ENABLED"] == "true"; var rabbitConfiguration = builder.Configuration.GetRabbitMqConfiguration(); -var redisConnectionString = isAspire ? builder.Configuration["ConnectionStrings:Redis"] : builder.Configuration["RedisHostName"]; -var dbConnectionString = isAspire ? builder.Configuration["ConnectionStrings:Database"] : builder.Configuration["ConnectionStrings:DefaultConnection"]; +var redisConnectionString = + isAspire ? builder.Configuration["ConnectionStrings:Redis"] : builder.Configuration["RedisHostName"]; +var dbConnectionString = isAspire + ? builder.Configuration["ConnectionStrings:Database"] + : builder.Configuration["ConnectionStrings:DefaultConnection"]; if (builder.Environment.IsProduction()) { diff --git a/CleanArchitecture.AppHost/Program.cs b/CleanArchitecture.AppHost/Program.cs index 607445d..4780d21 100644 --- a/CleanArchitecture.AppHost/Program.cs +++ b/CleanArchitecture.AppHost/Program.cs @@ -3,7 +3,7 @@ var redis = builder.AddRedis("Redis"); var rabbitPasswordRessource = new ParameterResource("password", _ => "guest"); -var rabbitPasswordParameter = +var rabbitPasswordParameter = builder.AddParameter("username", rabbitPasswordRessource.Value); var rabbitMq = builder @@ -22,4 +22,4 @@ .WithReference(db) .WaitFor(sqlServer); -builder.Build().Run(); +builder.Build().Run(); \ No newline at end of file diff --git a/CleanArchitecture.Domain/Rabbitmq/Extensions/ServiceCollectionExtensions.cs b/CleanArchitecture.Domain/Rabbitmq/Extensions/ServiceCollectionExtensions.cs index 21b7413..a785525 100644 --- a/CleanArchitecture.Domain/Rabbitmq/Extensions/ServiceCollectionExtensions.cs +++ b/CleanArchitecture.Domain/Rabbitmq/Extensions/ServiceCollectionExtensions.cs @@ -1,4 +1,3 @@ -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace CleanArchitecture.Domain.Rabbitmq.Extensions; diff --git a/CleanArchitecture.Domain/Rabbitmq/RabbitMqHandler.cs b/CleanArchitecture.Domain/Rabbitmq/RabbitMqHandler.cs index 2f8b80f..1d70e99 100644 --- a/CleanArchitecture.Domain/Rabbitmq/RabbitMqHandler.cs +++ b/CleanArchitecture.Domain/Rabbitmq/RabbitMqHandler.cs @@ -13,7 +13,6 @@ namespace CleanArchitecture.Domain.Rabbitmq; public sealed class RabbitMqHandler : BackgroundService { - private IChannel? _channel; private readonly RabbitMqConfiguration _configuration; private readonly ConcurrentDictionary> _consumers = new(); @@ -21,6 +20,7 @@ public sealed class RabbitMqHandler : BackgroundService private readonly ILogger _logger; private readonly ConcurrentQueue _pendingActions = new(); + private IChannel? _channel; public RabbitMqHandler( RabbitMqConfiguration configuration, @@ -46,7 +46,7 @@ public override async Task StartAsync(CancellationToken cancellationToken) HostName = _configuration.Host, Port = _configuration.Port, UserName = _configuration.Username, - Password = _configuration.Password, + Password = _configuration.Password }; var connection = await factory.CreateConnectionAsync(cancellationToken); @@ -133,14 +133,15 @@ public void AddExchangeConsumer(string exchange, string queue, ConsumeEventHandl AddExchangeConsumer(exchange, string.Empty, queue, consumer); } - private async Task AddEventConsumer(string exchange, string queueName, string routingKey, ConsumeEventHandler consumer) + private async Task AddEventConsumer(string exchange, string queueName, string routingKey, + ConsumeEventHandler consumer) { if (!_configuration.Enabled) { _logger.LogInformation("RabbitMQ is disabled. Event consumer will not be added."); return; } - + var key = $"{exchange}-{routingKey}"; if (!_consumers.TryGetValue(key, out var consumers)) diff --git a/CleanArchitecture.ServiceDefaults/Extensions.cs b/CleanArchitecture.ServiceDefaults/Extensions.cs index 8705c03..9d1b110 100644 --- a/CleanArchitecture.ServiceDefaults/Extensions.cs +++ b/CleanArchitecture.ServiceDefaults/Extensions.cs @@ -34,10 +34,7 @@ public static void AddServiceDefaults(this TBuilder builder) where TBu http.AddServiceDiscovery(); }); - builder.Services.Configure(options => - { - options.AllowedSchemes = ["https"]; - }); + builder.Services.Configure(options => { options.AllowedSchemes = ["https"]; }); } private static void ConfigureOpenTelemetry(this TBuilder builder) where TBuilder : IHostApplicationBuilder @@ -67,7 +64,8 @@ private static void ConfigureOpenTelemetry(this TBuilder builder) wher builder.AddOpenTelemetryExporters(); } - private static void AddOpenTelemetryExporters(this TBuilder builder) where TBuilder : IHostApplicationBuilder + private static void AddOpenTelemetryExporters(this TBuilder builder) + where TBuilder : IHostApplicationBuilder { var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]); @@ -100,4 +98,4 @@ public static void MapDefaultEndpoints(this WebApplication app) }); } } -} +} \ No newline at end of file