From c10fc5db98c045fcccbf44af7deaea1ac69f4cb8 Mon Sep 17 00:00:00 2001 From: Pc Date: Tue, 1 Aug 2023 02:26:38 +0330 Subject: [PATCH] chore: Remove additional files form building blocks --- src/BuildingBlocks/CAP/Extensions.cs | 55 ---------------------------- 1 file changed, 55 deletions(-) delete mode 100644 src/BuildingBlocks/CAP/Extensions.cs diff --git a/src/BuildingBlocks/CAP/Extensions.cs b/src/BuildingBlocks/CAP/Extensions.cs deleted file mode 100644 index f0a2a90..0000000 --- a/src/BuildingBlocks/CAP/Extensions.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Text.Encodings.Web; -using System.Text.Unicode; -using BuildingBlocks.Utils; -using BuildingBlocks.Web; -using DotNetCore.CAP; -using DotNetCore.CAP.Messages; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; - -namespace BuildingBlocks.CAP; - -public static class Extensions -{ - public static IServiceCollection AddCustomCap(this IServiceCollection services) - where TDbContext : DbContext - { - var rabbitMqOptions = services.GetOptions(nameof(RabbitMQOptions)); - - services.AddCap(x => - { - x.UseEntityFramework(); - x.UseRabbitMQ(o => - { - o.HostName = rabbitMqOptions.HostName; - o.UserName = rabbitMqOptions.UserName; - o.Password = rabbitMqOptions.Password; - }); - x.UseDashboard(); - x.FailedRetryCount = 5; - x.FailedThresholdCallback = failed => - { - var logger = failed.ServiceProvider.GetService(); - logger?.LogError( - $@"A message of type {failed.MessageType} failed after executing {x.FailedRetryCount} several times, - requiring manual troubleshooting. Message name: {failed.Message.GetName()}"); - }; - x.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); - }); - - // services.AddOpenTelemetryTracing((builder) => builder - // .AddAspNetCoreInstrumentation() - // .AddCapInstrumentation() - // .AddZipkinExporter() - // ); - - services.Scan(s => - s.FromAssemblies(AppDomain.CurrentDomain.GetAssemblies()) - .AddClasses(c => c.AssignableTo(typeof(ICapSubscribe))) - .AsImplementedInterfaces() - .WithScopedLifetime()); - - return services; - } -}