27 lines
970 B
C#
27 lines
970 B
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using Svrnty.CQRS.Notifications.Abstractions;
|
|
|
|
namespace Svrnty.CQRS.Notifications.Grpc;
|
|
|
|
/// <summary>
|
|
/// Extension methods for registering streaming notification services.
|
|
/// </summary>
|
|
public static class ServiceCollectionExtensions
|
|
{
|
|
/// <summary>
|
|
/// Adds gRPC streaming notification services to the service collection.
|
|
/// </summary>
|
|
/// <param name="services">The service collection.</param>
|
|
/// <returns>The service collection for chaining.</returns>
|
|
public static IServiceCollection AddStreamingNotifications(this IServiceCollection services)
|
|
{
|
|
// Subscription manager is singleton - shared state for all subscriptions
|
|
services.AddSingleton<NotificationSubscriptionManager>();
|
|
|
|
// Publisher can be singleton since it only depends on the manager
|
|
services.AddSingleton<INotificationPublisher, NotificationPublisher>();
|
|
|
|
return services;
|
|
}
|
|
}
|