// SPDX-License-Identifier: BUSL-1.1
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
using StellaOps.Messaging;
using StellaOps.Messaging.Abstractions;
using StellaOps.Provcache.Events;
using StellaOps.Provcache.Invalidation;
namespace StellaOps.Provcache;
public static partial class ProvcacheServiceCollectionExtensions
{
///
/// Adds event-driven invalidator services for Provcache.
///
/// The service collection.
/// The service collection for chaining.
public static IServiceCollection AddProvcacheInvalidators(this IServiceCollection services)
{
ArgumentNullException.ThrowIfNull(services);
services.TryAddSingleton>(sp =>
{
var factory = sp.GetRequiredService();
return factory.Create(new EventStreamOptions
{
StreamName = SignerRevokedEvent.StreamName
});
});
services.TryAddSingleton>(sp =>
{
var factory = sp.GetRequiredService();
return factory.Create(new EventStreamOptions
{
StreamName = FeedEpochAdvancedEvent.StreamName
});
});
services.TryAddEnumerable(ServiceDescriptor.Singleton());
services.TryAddEnumerable(ServiceDescriptor.Singleton());
services.TryAddEnumerable(ServiceDescriptor.Singleton());
return services;
}
}