Skip to content

Commit

Permalink
Merge registration methods
Browse files Browse the repository at this point in the history
  • Loading branch information
wsugarman committed Oct 5, 2023
1 parent 76fde76 commit 36f3b36
Showing 1 changed file with 21 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,38 +40,18 @@ public static IDicomServerBuilder AddSqlServer(
IConfiguration configurationRoot,
Action<SqlServerDataStoreConfiguration> configureAction = null)
{
IServiceCollection services = EnsureArg.IsNotNull(dicomServerBuilder, nameof(dicomServerBuilder)).Services;

// Add core SQL services
IConfigurationSection config = EnsureArg
.IsNotNull(configurationRoot, nameof(configurationRoot))
.GetSection(SqlServerDataStoreConfiguration.SectionName);

services
.AddSqlServerConnection(
sqlOptions =>
{
config.Bind(sqlOptions);
configureAction?.Invoke(sqlOptions);
})
EnsureArg.IsNotNull(dicomServerBuilder, nameof(dicomServerBuilder));
EnsureArg.IsNotNull(configurationRoot, nameof(configurationRoot));

dicomServerBuilder.Services
.AddCommonSqlServices(sqlOptions =>
{
configurationRoot.GetSection(SqlServerDataStoreConfiguration.SectionName).Bind(sqlOptions);
configureAction?.Invoke(sqlOptions);
})
.AddSqlServerManagement<SchemaVersion>()
.AddSqlServerApi()
.AddBackgroundSqlSchemaVersionResolver();

// Optionally enable workload identity
DicomSqlServerOptions options = new();
config.Bind(options);
if (options.EnableWorkloadIdentity)
services.EnableWorkloadManagedIdentity();

// Add SQL-specific implementations
services
.AddSqlChangeFeedStores()
.AddSqlExtendedQueryTagStores()
.AddSqlExtendedQueryTagErrorStores()
.AddSqlIndexDataStores()
.AddSqlInstanceStores()
.AddSqlPartitionStores()
.AddBackgroundSqlSchemaVersionResolver()
.AddSqlQueryStores()
.AddSqlWorkitemStores();

Expand All @@ -85,20 +65,25 @@ public static IDicomFunctionsBuilder AddSqlServer(
EnsureArg.IsNotNull(dicomFunctionsBuilder, nameof(dicomFunctionsBuilder));
EnsureArg.IsNotNull(configureAction, nameof(configureAction));

IServiceCollection services = dicomFunctionsBuilder.Services;
dicomFunctionsBuilder.Services
.AddCommonSqlServices(configureAction)
.AddForegroundSqlSchemaVersionResolver();

return dicomFunctionsBuilder;
}

private static IServiceCollection AddCommonSqlServices(this IServiceCollection services, Action<SqlServerDataStoreConfiguration> configureAction)
{
// Add core SQL services
services
.AddSqlServerConnection(configureAction)
.AddForegroundSqlSchemaVersionResolver();
services.AddSqlServerConnection(configureAction);

// Optionally enable workload identity
DicomSqlServerOptions options = new();
configureAction(options);
if (options.EnableWorkloadIdentity)
services.EnableWorkloadManagedIdentity();

// Add SQL-specific implementations
// Add SQL-specific data store implementations
services
.AddSqlExtendedQueryTagStores()
.AddSqlExtendedQueryTagErrorStores()
Expand All @@ -107,7 +92,7 @@ public static IDicomFunctionsBuilder AddSqlServer(
.AddSqlPartitionStores()
.AddSqlChangeFeedStores();

return dicomFunctionsBuilder;
return services;
}

private static IServiceCollection AddBackgroundSqlSchemaVersionResolver(this IServiceCollection services)
Expand Down

0 comments on commit 36f3b36

Please sign in to comment.