28 lines
1.1 KiB
C#
28 lines
1.1 KiB
C#
using LiteCharms.Abstractions;
|
|
using LiteCharms.Infrastructure.ServiceBus;
|
|
using LiteCharms.Infrastructure.ServiceBus.Exchanges;
|
|
using LiteCharms.Infrastructure.ServiceBus.Queues;
|
|
|
|
namespace LiteCharms.Extensions;
|
|
|
|
public static class ServiceBus
|
|
{
|
|
public static IServiceCollection AddGeneralServiceBus(this IServiceCollection services) => services
|
|
.AddSingleton<GeneralQueue>()
|
|
.AddHostedService<GeneralExchange>()
|
|
.AddKeyedSingleton<IEventBus, GeneralServiceBus>(Constants.GeneralServiceBus)
|
|
.AddMemoryCache();
|
|
|
|
public static IServiceCollection AddEmailServiceBus(this IServiceCollection services) => services
|
|
.AddSingleton<EmailQueue>()
|
|
.AddHostedService<EmailExchange>()
|
|
.AddKeyedTransient<IEventBus, EmailServiceBus>(Constants.EmailServiceBus)
|
|
.AddMemoryCache();
|
|
|
|
public static IServiceCollection AddSalesServiceBus(this IServiceCollection services) => services
|
|
.AddSingleton<SalesQueue>()
|
|
.AddHostedService<SalesExchange>()
|
|
.AddKeyedSingleton<IEventBus, SalesServiceBus>(Constants.SalesServiceBus)
|
|
.AddMemoryCache();
|
|
}
|