56 lines
2.2 KiB
C#
56 lines
2.2 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using StellaOps.Graph.Indexer.Analytics;
|
|
using StellaOps.Graph.Indexer.Incremental;
|
|
using StellaOps.Graph.Indexer.Ingestion.Sbom;
|
|
using StellaOps.Graph.Indexer.Persistence.Postgres;
|
|
using StellaOps.Graph.Indexer.Persistence.Postgres.Repositories;
|
|
using StellaOps.Infrastructure.Postgres.Options;
|
|
|
|
namespace StellaOps.Graph.Indexer.Persistence.Extensions;
|
|
|
|
/// <summary>
|
|
/// Extension methods for configuring Graph.Indexer persistence services.
|
|
/// </summary>
|
|
public static class GraphIndexerPersistenceExtensions
|
|
{
|
|
/// <summary>
|
|
/// Adds Graph.Indexer PostgreSQL persistence services.
|
|
/// </summary>
|
|
public static IServiceCollection AddGraphIndexerPersistence(
|
|
this IServiceCollection services,
|
|
IConfiguration configuration,
|
|
string sectionName = "Postgres:Graph")
|
|
{
|
|
services.Configure<PostgresOptions>(configuration.GetSection(sectionName));
|
|
services.AddSingleton<GraphIndexerDataSource>();
|
|
|
|
// Register repositories
|
|
services.AddSingleton<IIdempotencyStore, PostgresIdempotencyStore>();
|
|
services.AddSingleton<IGraphSnapshotProvider, PostgresGraphSnapshotProvider>();
|
|
services.AddSingleton<IGraphAnalyticsWriter, PostgresGraphAnalyticsWriter>();
|
|
services.AddSingleton<IGraphDocumentWriter, PostgresGraphDocumentWriter>();
|
|
|
|
return services;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adds Graph.Indexer PostgreSQL persistence services with explicit options.
|
|
/// </summary>
|
|
public static IServiceCollection AddGraphIndexerPersistence(
|
|
this IServiceCollection services,
|
|
Action<PostgresOptions> configureOptions)
|
|
{
|
|
services.Configure(configureOptions);
|
|
services.AddSingleton<GraphIndexerDataSource>();
|
|
|
|
// Register repositories
|
|
services.AddSingleton<IIdempotencyStore, PostgresIdempotencyStore>();
|
|
services.AddSingleton<IGraphSnapshotProvider, PostgresGraphSnapshotProvider>();
|
|
services.AddSingleton<IGraphAnalyticsWriter, PostgresGraphAnalyticsWriter>();
|
|
services.AddSingleton<IGraphDocumentWriter, PostgresGraphDocumentWriter>();
|
|
|
|
return services;
|
|
}
|
|
}
|