private static IServiceProvider Register(IServiceCollection builder, IConfigurationRoot config) { builder .AddSingleton <OnNotificationEventTrigger>(); builder .AddSingleton <INotificationService, NotificationService>(); builder.AddFeatureToggling(config); builder.AddServiceBus(config); builder.AddApplicationInsights(config, "CalculateFunding.Functions.Notifications"); builder.AddApplicationInsightsTelemetryClient(config, "CalculateFunding.Functions.Notifications"); builder.AddLogging("CalculateFunding.Functions.Notifications"); builder.AddTelemetry(); builder.AddPolicySettings(config); builder.AddSingleton <INotificationsResiliencePolicies>((ctx) => { PolicySettings policySettings = ctx.GetService <PolicySettings>(); BulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); return(new NotificationsResiliencePolicies { MessagePolicy = ResiliencePolicyHelpers.GenerateMessagingPolicy(totalNetworkRequestsPolicy), }); }); return(builder.BuildServiceProvider()); }
private static ResiliencePolicies CreateResiliencePolicies(PolicySettings policySettings) { AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); ResiliencePolicies resiliencePolicies = new ResiliencePolicies { CalculationResultsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(), JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), ProvidersApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), PublishedProviderVersionRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), SpecificationsRepositoryPolicy = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), BlobClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), CalculationsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), PublishedFundingRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(), PoliciesApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), ProfilingApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), FundingFeedSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy), PublishedFundingBlobRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), PublishedProviderSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy), PublishedIndexSearchResiliencePolicy = PublishedIndexSearchResiliencePolicy.GeneratePublishedIndexSearch(), SpecificationsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), CacheProvider = ResiliencePolicyHelpers.GenerateRedisPolicy(totalNetworkRequestsPolicy) }; return(resiliencePolicies); }
internal IServiceCollection ConfigureServices(IServiceCollection builder) { builder.AddTransient <IPublishedProviderContentsGenerator, PublishedProviderContentsGenerator>(); builder.AddTransient <IPublishedFundingContentsGenerator, PublishedFundingContentsGenerator>(); builder.AddTransient <Providers.v1.ProviderDocumentGenerator>(); builder.AddTransient <Providers.v2.ProviderDocumentGenerator>(); builder.AddApplicationInsightsTelemetryClient(Configuration, "CalculateFunding.Generators.NavFeed"); builder.AddLogging("CalculateFunding.Generators.NavFeed"); builder.AddProvidersInterServiceClient(Configuration); builder.AddPolicySettings(Configuration); builder.AddSingleton <IOrganisationGroupResiliencePolicies>((ctx) => { PolicySettings policySettings = ctx.GetService <PolicySettings>(); AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); return(new OrganisationGroupResiliencePolicies { ProvidersApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy) }); }); return(builder); }
public static IServiceCollection AddCalcsResiliencePolicies(this IServiceCollection serviceCollection) { serviceCollection.AddSingleton <ICalcsResiliencePolicies>((ctx) => { PolicySettings policySettings = ctx.GetService <PolicySettings>(); AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); return(new ResiliencePolicies { CalculationsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), CalculationsSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy), CacheProviderPolicy = ResiliencePolicyHelpers.GenerateRedisPolicy(totalNetworkRequestsPolicy), CalculationsVersionsRepositoryPolicy = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), SpecificationsRepositoryPolicy = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), BuildProjectRepositoryPolicy = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), MessagePolicy = ResiliencePolicyHelpers.GenerateMessagingPolicy(totalNetworkRequestsPolicy), JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), SourceFilesRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), DatasetsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), PoliciesApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), ResultsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), }); }); return(serviceCollection); }
public static IServiceProvider BuildServiceProvider() { IServiceCollection serviceCollection = new ServiceCollection(); serviceCollection.AddApplicationInsightsTelemetryClient(_configuration, "CalculateFunding.Migrations.PublishedProviderPopulateReleased"); serviceCollection.AddLogging(serviceName: "CalculateFunding.Migrations.PublishedProviderPopulateReleased"); serviceCollection.AddPolicySettings(_configuration); serviceCollection.AddSingleton <ICosmosRepository>(ctx => { CosmosDbSettings cosmosDbSettings = new CosmosDbSettings(); _configuration.Bind("CosmosDbSettings", cosmosDbSettings); cosmosDbSettings.ContainerName = "publishedfunding"; return(new CosmosRepository(cosmosDbSettings)); }); serviceCollection.AddSingleton <IPublishingResiliencePolicies>(ctx => { PolicySettings policySettings = ctx.GetService <PolicySettings>(); AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers .GenerateTotalNetworkRequestsPolicy(policySettings); return(new ResiliencePolicies { PublishedProviderVersionRepository = ResiliencePolicyHelpers .GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy) }); }); serviceCollection.AddTransient <IPublishedProviderMigration, PublishedProviderMigration>(); return(serviceCollection.BuildServiceProvider()); }
private static ResiliencePolicies CreateResiliencePolicies(PolicySettings policySettings) { AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); ResiliencePolicies resiliencePolicies = new ResiliencePolicies() { CalculationProviderResultsSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy), ResultsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), ResultsSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy), SpecificationsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), ProviderProfilingRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), PublishedProviderCalculationResultsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), PublishedProviderResultsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), CalculationsRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), ProviderCalculationResultsSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy), ProviderChangesRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), PoliciesApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), CalculationsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), BlobClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), CacheProvider = ResiliencePolicyHelpers.GenerateRedisPolicy(totalNetworkRequestsPolicy) }; return(resiliencePolicies); }
private static OrganisationGroupResiliencePolicies CreateResiliencePolicies(PolicySettings policySettings) { AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); OrganisationGroupResiliencePolicies resiliencePolicies = new OrganisationGroupResiliencePolicies { ProvidersApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy) }; return(resiliencePolicies); }
private static CalculatorResiliencePolicies CreateResiliencePolicies(PolicySettings policySettings) { BulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); CalculatorResiliencePolicies resiliencePolicies = new CalculatorResiliencePolicies() { ProviderResultsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), ProviderSourceDatasetsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), CacheProvider = ResiliencePolicyHelpers.GenerateRedisPolicy(totalNetworkRequestsPolicy), Messenger = ResiliencePolicyHelpers.GenerateMessagingPolicy(totalNetworkRequestsPolicy), CalculationsRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy) }; return(resiliencePolicies); }
private static PolicyResiliencePolicies CreateResiliencePolicies(PolicySettings policySettings) { AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); return(new PolicyResiliencePolicies { PolicyRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), CacheProvider = ResiliencePolicyHelpers.GenerateRedisPolicy(totalNetworkRequestsPolicy), FundingSchemaRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), FundingTemplateRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), TemplatesSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy), JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), TemplatesRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), SpecificationsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), ResultsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), CalculationsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy) }); }
private static ResiliencePolicies CreateResiliencePolicies(PolicySettings policySettings) { BulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); return(new ResiliencePolicies { CalculationsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), CalculationsSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy), CacheProviderPolicy = ResiliencePolicyHelpers.GenerateRedisPolicy(totalNetworkRequestsPolicy), CalculationsVersionsRepositoryPolicy = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), SpecificationsRepositoryPolicy = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), BuildProjectRepositoryPolicy = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), MessagePolicy = ResiliencePolicyHelpers.GenerateMessagingPolicy(totalNetworkRequestsPolicy), JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), SourceFilesRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), DatasetsRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy) }); }
private static DatasetsResiliencePolicies CreateResiliencePolicies(PolicySettings policySettings) { AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); return(new DatasetsResiliencePolicies { SpecificationsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), CacheProviderRepository = ResiliencePolicyHelpers.GenerateRedisPolicy(totalNetworkRequestsPolicy), ProviderResultsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), ProviderRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), DatasetRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), DatasetSearchService = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy), DatasetDefinitionSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy), BlobClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), ProvidersApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), PoliciesApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), CalculationsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy) }); }
private static IServiceProvider Register(IServiceCollection builder, IConfigurationRoot config) { // These registrations of the functions themselves are just for the DebugQueue. Ideally we don't want these registered in production if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development") { builder .AddSingleton <OnNotificationEventTrigger>(); } builder.AddSingleton <IUserProfileProvider, UserProfileProvider>(); builder .AddSingleton <INotificationService, NotificationService>(); builder.AddFeatureToggling(config); builder.AddServiceBus(config, "notifications"); builder.AddApplicationInsightsTelemetryClient(config, "CalculateFunding.Functions.Notifications"); builder.AddApplicationInsightsServiceName(config, "CalculateFunding.Functions.Notifications"); builder.AddLogging("CalculateFunding.Functions.Notifications"); builder.AddTelemetry(); builder.AddPolicySettings(config); builder.AddSingleton <INotificationsResiliencePolicies>((ctx) => { PolicySettings policySettings = ctx.GetService <PolicySettings>(); AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); return(new NotificationsResiliencePolicies { MessagePolicy = ResiliencePolicyHelpers.GenerateMessagingPolicy(totalNetworkRequestsPolicy), }); }); builder.AddScoped <IUserProfileProvider, UserProfileProvider>(); return(builder.BuildServiceProvider()); }
public static IServiceProvider BuildServiceProvider(IApiOptions options) { IServiceCollection serviceCollection = new ServiceCollection(); serviceCollection.AddLogging("CalculateFunding.Migrations.ProviderVersionDefectCorrection"); serviceCollection.AddPolicySettings(Configuration); serviceCollection.AddSingleton <ICalculationsEtlResiliencePolicies>(ctx => { PolicySettings policySettings = ctx.GetService <PolicySettings>(); AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers .GenerateTotalNetworkRequestsPolicy(policySettings); return(new ResiliencePolicies { CalculationsApiClient = GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), SpecificationApiClient = GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), DataSetsApiClient = GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy) }); }); AddHttpClientForClientKey(HttpClientKeys.Specifications, options.SpecificationsApiUri, options.SpecificationsApiKey, serviceCollection); AddHttpClientForClientKey(HttpClientKeys.Calculations, options.CalculationsApiUri, options.CalculationsApiKey, serviceCollection); AddHttpClientForClientKey(HttpClientKeys.Datasets, options.DataSetsApiUri, options.DataSetsApiKey, serviceCollection); serviceCollection.AddSingleton <ICalculationsApiClient, CalculationsApiClient>(); serviceCollection.AddTransient <ISpecificationsApiClient, SpecificationsApiClient>(); serviceCollection.AddTransient <IDatasetsApiClient, DatasetsApiClient>(); return(serviceCollection.BuildServiceProvider()); }
private static IServiceProvider Register(IServiceCollection builder, IConfigurationRoot config) { // These registrations of the functions themselves are just for the DebugQueue. Ideally we don't want these registered in production if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development") { builder.AddScoped <OnEditSpecificationEvent>(); } builder.AddSingleton <IUserProfileProvider, UserProfileProvider>(); builder .AddSingleton <IUserService, UserService>() .AddSingleton <IHealthChecker, UserService>(); builder .AddSingleton <IFundingStreamPermissionService, FundingStreamPermissionService>() .AddSingleton <IHealthChecker, FundingStreamPermissionService>(); builder.AddSingleton <IValidator <UserCreateModel>, UserCreateModelValidator>(); builder.AddSingleton <IUserRepository, UserRepository>((ctx) => { CosmosDbSettings usersDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", usersDbSettings); usersDbSettings.ContainerName = "users"; CosmosRepository usersCosmosRepostory = new CosmosRepository(usersDbSettings); return(new UserRepository(usersCosmosRepostory)); }); MapperConfiguration mappingConfig = new MapperConfiguration(c => c.AddProfile <UsersMappingProfile>()); builder.AddSingleton(mappingConfig.CreateMapper()); builder.AddSingleton <IVersionRepository <FundingStreamPermissionVersion>, VersionRepository <FundingStreamPermissionVersion> >((ctx) => { CosmosDbSettings versioningDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", versioningDbSettings); versioningDbSettings.ContainerName = "users"; CosmosRepository versioningRepository = new CosmosRepository(versioningDbSettings); return(new VersionRepository <FundingStreamPermissionVersion>(versioningRepository, new NewVersionBuilderFactory <FundingStreamPermissionVersion>())); }); builder.AddPolicySettings(config); builder.AddSingleton <IUsersResiliencePolicies>((ctx) => { PolicySettings policySettings = ctx.GetService <PolicySettings>(); AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); return(new UsersResiliencePolicies { FundingStreamPermissionVersionRepositoryPolicy = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), CacheProviderPolicy = ResiliencePolicyHelpers.GenerateRedisPolicy(totalNetworkRequestsPolicy), SpecificationApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), UserRepositoryPolicy = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), }); }); builder.AddCaching(config); builder.AddApplicationInsightsTelemetryClient(config, "CalculateFunding.Functions.Users"); builder.AddApplicationInsightsServiceName(config, "CalculateFunding.Functions.Users"); builder.AddLogging("CalculateFunding.Functions.Users"); builder.AddServiceBus(config, "users"); builder.AddTelemetry(); builder.AddSpecificationsInterServiceClient(config); builder.AddScoped <IUserProfileProvider, UserProfileProvider>(); return(builder.BuildServiceProvider()); }
private static IServiceProvider Register(IServiceCollection builder, IConfigurationRoot config) { builder.AddSingleton <OnDataDefinitionChanges>(); builder.AddSingleton <OnEditCaluclationEvent>(); builder.AddSingleton <OnEditSpecificationEvent>(); builder.AddSingleton <IScenariosRepository, ScenariosRepository>(); builder.AddSingleton <IScenariosService, ScenariosService>(); builder.AddSingleton <IScenariosSearchService, ScenariosSearchService>(); builder .AddSingleton <IValidator <CreateNewTestScenarioVersion>, CreateNewTestScenarioVersionValidator>(); builder .AddSingleton <ISpecificationsRepository, SpecificationsRepository>(); builder .AddSingleton <IBuildProjectRepository, BuildProjectRepository>(); builder .AddSingleton <ICalcsRepository, CalcsRepository>(); builder .AddSingleton <ICancellationTokenProvider, InactiveCancellationTokenProvider>(); builder .AddSingleton <IDatasetRepository, DatasetRepository>(); builder .AddSingleton <IDatasetDefinitionFieldChangesProcessor, DatasetDefinitionFieldChangesProcessor>(); builder.AddSingleton <IVersionRepository <TestScenarioVersion>, VersionRepository <TestScenarioVersion> >((ctx) => { CosmosDbSettings scenariosVersioningDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", scenariosVersioningDbSettings); scenariosVersioningDbSettings.CollectionName = "tests"; CosmosRepository resultsRepostory = new CosmosRepository(scenariosVersioningDbSettings); return(new VersionRepository <TestScenarioVersion>(resultsRepostory)); }); builder.AddCalcsInterServiceClient(config); builder.AddSpecificationsInterServiceClient(config); builder.AddDatasetsInterServiceClient(config); if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development") { builder.AddCosmosDb(config, "tests"); } else { builder.AddCosmosDb(config); } builder.AddJobsInterServiceClient(config); builder.AddSearch(config); builder.AddServiceBus(config); builder.AddCaching(config); builder.AddApplicationInsights(config, "CalculateFunding.Functions.Scenarios"); builder.AddApplicationInsightsTelemetryClient(config, "CalculateFunding.Functions.Scenarios"); builder.AddLogging("CalculateFunding.Functions.Scenarios"); builder.AddTelemetry(); builder.AddFeatureToggling(config); builder.AddPolicySettings(config); builder.AddSingleton <IScenariosResiliencePolicies>((ctx) => { PolicySettings policySettings = ctx.GetService <PolicySettings>(); BulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); Policy redisPolicy = ResiliencePolicyHelpers.GenerateRedisPolicy(totalNetworkRequestsPolicy); return(new ScenariosResiliencePolicies() { CalcsRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), DatasetRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), ScenariosRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy) }); }); return(builder.BuildServiceProvider()); }
private static IServiceProvider Register(IServiceCollection builder, IConfigurationRoot config) { builder.AddSingleton <OnCosmosDbDiagnosticsReceived>(); builder.AddSingleton <OnScaleUpCosmosDbCollection>(); builder.AddSingleton <OnIncrementalScaleDownCosmosDbCollection>(); builder.AddSingleton <OnScaleDownCosmosDbCollection>(); builder.AddSingleton <ICosmosDbScalingRepositoryProvider, CosmosDbScalingRepositoryProvider>(); builder.AddSingleton <ICosmosDbScalingService, CosmosDbScalingService>(); builder.AddSingleton <ICosmosDbScalingRequestModelBuilder, CosmosDbScalingRequestModelBuilder>(); builder.AddSingleton <ICosmosDbThrottledEventsFilter, CosmosDbThrottledEventsFilter>(); builder.AddSingleton <CalculationProviderResultsScalingRepository>((ctx) => { CosmosDbSettings cosmosDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", cosmosDbSettings); cosmosDbSettings.CollectionName = "calculationresults"; CosmosRepository cosmosRepostory = new CosmosRepository(cosmosDbSettings); return(new CalculationProviderResultsScalingRepository(cosmosRepostory)); }); builder.AddSingleton <ProviderSourceDatasetsScalingRepository>((ctx) => { CosmosDbSettings cosmosDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", cosmosDbSettings); cosmosDbSettings.CollectionName = "providerdatasets"; CosmosRepository cosmosRepository = new CosmosRepository(cosmosDbSettings); return(new ProviderSourceDatasetsScalingRepository(cosmosRepository)); }); builder.AddSingleton <CalculationsScalingRepository>((ctx) => { CosmosDbSettings cosmosDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", cosmosDbSettings); cosmosDbSettings.CollectionName = "calcs"; CosmosRepository cosmosRepository = new CosmosRepository(cosmosDbSettings); return(new CalculationsScalingRepository(cosmosRepository)); }); builder.AddSingleton <JobsScalingRepository>((ctx) => { CosmosDbSettings cosmosDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", cosmosDbSettings); cosmosDbSettings.CollectionName = "jobs"; CosmosRepository cosmosRepository = new CosmosRepository(cosmosDbSettings); return(new JobsScalingRepository(cosmosRepository)); }); builder.AddSingleton <DatasetAggregationsScalingRepository>((ctx) => { CosmosDbSettings cosmosDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", cosmosDbSettings); cosmosDbSettings.CollectionName = "datasetaggregations"; CosmosRepository cosmosRepository = new CosmosRepository(cosmosDbSettings); return(new DatasetAggregationsScalingRepository(cosmosRepository)); }); builder.AddSingleton <DatasetsScalingRepository>((ctx) => { CosmosDbSettings cosmosDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", cosmosDbSettings); cosmosDbSettings.CollectionName = "datasets"; CosmosRepository cosmosRepository = new CosmosRepository(cosmosDbSettings); return(new DatasetsScalingRepository(cosmosRepository)); }); builder.AddSingleton <ProfilingScalingRepository>((ctx) => { CosmosDbSettings cosmosDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", cosmosDbSettings); cosmosDbSettings.CollectionName = "profiling"; CosmosRepository cosmosRepository = new CosmosRepository(cosmosDbSettings); return(new ProfilingScalingRepository(cosmosRepository)); }); builder.AddSingleton <SpecificationsScalingRepository>((ctx) => { CosmosDbSettings cosmosDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", cosmosDbSettings); cosmosDbSettings.CollectionName = "specs"; CosmosRepository cosmosRepository = new CosmosRepository(cosmosDbSettings); return(new SpecificationsScalingRepository(cosmosRepository)); }); builder.AddSingleton <TestResultsScalingRepository>((ctx) => { CosmosDbSettings cosmosDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", cosmosDbSettings); cosmosDbSettings.CollectionName = "testresults"; CosmosRepository cosmosRepository = new CosmosRepository(cosmosDbSettings); return(new TestResultsScalingRepository(cosmosRepository)); }); builder.AddSingleton <TestsScalingRepository>((ctx) => { CosmosDbSettings cosmosDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", cosmosDbSettings); cosmosDbSettings.CollectionName = "tests"; CosmosRepository cosmosRepository = new CosmosRepository(cosmosDbSettings); return(new TestsScalingRepository(cosmosRepository)); }); builder.AddSingleton <UsersScalingRepository>((ctx) => { CosmosDbSettings cosmosDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", cosmosDbSettings); cosmosDbSettings.CollectionName = "users"; CosmosRepository cosmosRepository = new CosmosRepository(cosmosDbSettings); return(new UsersScalingRepository(cosmosRepository)); }); builder.AddSingleton <PublishedProviderResultsScalingRepository>((ctx) => { CosmosDbSettings cosmosDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", cosmosDbSettings); cosmosDbSettings.CollectionName = "publishedproviderresults"; CosmosRepository cosmosRepository = new CosmosRepository(cosmosDbSettings); return(new PublishedProviderResultsScalingRepository(cosmosRepository)); }); builder.AddSingleton <ICosmosDbScalingConfigRepository>((ctx) => { CosmosDbSettings cosmosDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", cosmosDbSettings); cosmosDbSettings.CollectionName = "cosmosscalingconfig"; CosmosRepository cosmosRepository = new CosmosRepository(cosmosDbSettings); return(new CosmosDbScalingConfigRepository(cosmosRepository)); }); builder.AddCaching(config); builder.AddJobsInterServiceClient(config); builder.AddServiceBus(config); builder.AddApplicationInsightsTelemetryClient(config, "CalculateFunding.Functions.CosmosDbScaling"); builder.AddLogging("CalculateFunding.Functions.CosmosDbScaling", config); builder.AddTelemetry(); builder.AddFeatureToggling(config); builder.AddSingleton <ICosmosDbScallingResilliencePolicies>(m => { PolicySettings policySettings = builder.GetPolicySettings(config); BulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); CosmosDbScallingResilliencePolicies resiliencePolicies = new CosmosDbScallingResilliencePolicies() { ScalingRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), ScalingConfigRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), CacheProvider = ResiliencePolicyHelpers.GenerateRedisPolicy(totalNetworkRequestsPolicy) }; return(resiliencePolicies); }); return(builder.BuildServiceProvider()); }
private static IServiceProvider Register(IServiceCollection builder, IConfigurationRoot config) { // These registrations of the functions themselves are just for the DebugQueue. Ideally we don't want these registered in production if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development") { builder.AddScoped <OnTestSpecificationProviderResultsCleanup>(); builder.AddScoped <OnEditSpecificationEvent>(); builder.AddScoped <OnTestExecution>(); builder.AddScoped <OnDeleteTestResults>(); builder.AddScoped <OnDeleteTestResultsFailure>(); } builder.AddSingleton <IUserProfileProvider, UserProfileProvider>(); builder .AddSingleton <IGherkinParserService, GherkinParserService>(); builder .AddSingleton <IGherkinParser, GherkinParser>(); builder .AddSingleton <ICodeMetadataGeneratorService, ReflectionCodeMetadataGenerator>(); builder .AddSingleton <IStepParserFactory, StepParserFactory>(); builder.AddSingleton <ITestResultsRepository, TestResultsRepository>((ctx) => { CosmosDbSettings testResultsDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", testResultsDbSettings); testResultsDbSettings.ContainerName = "testresults"; CosmosRepository providersCosmosRepostory = new CosmosRepository(testResultsDbSettings); EngineSettings engineSettings = ctx.GetService <EngineSettings>(); ILogger logger = ctx.GetService <ILogger>(); return(new TestResultsRepository(providersCosmosRepostory, logger, engineSettings)); }); builder .AddSingleton <IScenariosRepository, ScenariosRepository>(); builder .AddScoped <ITestEngineService, TestEngineService>(); builder .AddSingleton <ITestEngine, Services.TestRunner.TestEngine>(); builder .AddSingleton <IGherkinExecutor, GherkinExecutor>(); builder .AddSingleton <ICalculationsRepository, CalculationsRepository>(); builder.AddSingleton <ICosmosRepository, CosmosRepository>(); builder.AddSingleton <IProviderSourceDatasetsRepository, ProviderSourceDatasetsRepository>((ctx) => { CosmosDbSettings providersDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", providersDbSettings); providersDbSettings.ContainerName = "providerdatasets"; CosmosRepository providersCosmosRepostory = new CosmosRepository(providersDbSettings); EngineSettings engineSettings = ctx.GetService <EngineSettings>(); return(new ProviderSourceDatasetsRepository(providersCosmosRepostory, engineSettings)); }); builder.AddSingleton <IProviderResultsRepository, ProviderResultsRepository>((ctx) => { CosmosDbSettings providersDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", providersDbSettings); providersDbSettings.ContainerName = "calculationresults"; CosmosRepository providersCosmosRepostory = new CosmosRepository(providersDbSettings); return(new ProviderResultsRepository(providersCosmosRepostory)); }); builder.AddSingleton <ITestResultsSearchService, TestResultsSearchService>(); builder.AddSingleton <ITestResultsCountsService, TestResultsCountsService>(); builder.AddSingleton <IJobManagement, JobManagement>(); builder.AddSingleton <IDeadletterService, DeadletterService>(); MapperConfiguration mappingConfiguration = new MapperConfiguration(c => { c.AddProfile <TestEngineMappingProfile>(); }); builder .AddSingleton(mappingConfiguration.CreateMapper()); builder.AddScoped <ITestResultsService, TestResultsService>(); builder.AddSearch(config); builder .AddSingleton <ISearchRepository <TestScenarioResultIndex>, SearchRepository <TestScenarioResultIndex> >(); builder.AddSpecificationsInterServiceClient(config, handlerLifetime: Timeout.InfiniteTimeSpan); builder.AddScenariosInterServiceClient(config); builder.AddCalculationsInterServiceClient(config, handlerLifetime: Timeout.InfiniteTimeSpan); builder.AddProvidersInterServiceClient(config, handlerLifetime: Timeout.InfiniteTimeSpan); builder.AddJobsInterServiceClient(config, handlerLifetime: Timeout.InfiniteTimeSpan); builder.AddCaching(config); builder.AddApplicationInsightsTelemetryClient(config, "CalculateFunding.Functions.TestEngine", TelemetryChannelType.Sync); builder.AddApplicationInsightsServiceName(config, "CalculateFunding.Functions.TestEngine"); builder.AddLogging("CalculateFunding.Functions.TestEngine"); builder.AddServiceBus(config, "testengine"); builder.AddTelemetry(); builder.AddEngineSettings(config); builder.AddPolicySettings(config); builder.AddFeatureToggling(config); builder.AddSingleton((Func <IServiceProvider, ITestRunnerResiliencePolicies>)((ctx) => { PolicySettings policySettings = ctx.GetService <PolicySettings>(); AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); AsyncPolicy redisPolicy = ResiliencePolicyHelpers.GenerateRedisPolicy(totalNetworkRequestsPolicy); ResiliencePolicies resiliencePolicies = new ResiliencePolicies() { CalculationsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), CacheProviderRepository = redisPolicy, ProviderResultsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), ProviderSourceDatasetsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), ScenariosRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(new[] { totalNetworkRequestsPolicy, redisPolicy }), SpecificationsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), TestResultsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), TestResultsSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy) }; return(resiliencePolicies); })); builder.AddSingleton <IJobManagementResiliencePolicies>((ctx) => { PolicySettings policySettings = ctx.GetService <PolicySettings>(); AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); return(new JobManagementResiliencePolicies() { JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), }); }); builder.AddScoped <IUserProfileProvider, UserProfileProvider>(); return(builder.BuildServiceProvider()); }
public static IServiceProvider BuildServiceProvider(string collectionName) { IServiceCollection builder = new ServiceCollection(); builder.AddApplicationInsightsTelemetryClient(Configuration, ServiceName); builder.AddLogging(serviceName: ServiceName); builder.AddSingleton <IProducerConsumerFactory, ProducerConsumerFactory>(); builder.AddPolicySettings(Configuration); builder.AddSingleton <IJobManagement, JobManagement>(); builder.AddSingleton <IJobTracker, JobTracker>(); builder.AddJobsInterServiceClient(Configuration, handlerLifetime: Timeout.InfiniteTimeSpan); builder.AddServiceBus(Configuration); builder.AddSingleton <IUserProfileProvider, UserProfileProvider>(); builder.AddSingleton <ICosmosRepository>(ctx => { CosmosDbSettings cosmosDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", cosmosDbSettings); cosmosDbSettings.ContainerName = collectionName; return(new CosmosRepository(cosmosDbSettings)); }); builder.AddSingleton <IPublishingResiliencePolicies>(ctx => { PolicySettings policySettings = ctx.GetService <PolicySettings>(); AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers .GenerateTotalNetworkRequestsPolicy(policySettings); return(new ResiliencePolicies { JobsApiClient = ResiliencePolicyHelpers .GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), PublishedFundingRepository = ResiliencePolicyHelpers .GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), PublishedIndexSearchResiliencePolicy = ResiliencePolicyHelpers .GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), BlobClient = ResiliencePolicyHelpers .GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy) }); }); builder.AddSingleton <IJobManagementResiliencePolicies>(ctx => { PolicySettings policySettings = ctx.GetService <PolicySettings>(); AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers .GenerateTotalNetworkRequestsPolicy(policySettings); return(new JobManagementResiliencePolicies { JobsApiClient = ResiliencePolicyHelpers .GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy) }); }); builder.AddSingleton <IPublishedFundingUndoCosmosRepository, PublishedFundingUndoCosmosRepository>(); builder.AddSingleton <IPublishedFundingUndoBlobStoreRepository>(ctx => { BlobStorageOptions settings = new BlobStorageOptions(); Configuration.Bind("AzureStorageSettings", settings); settings.ContainerName = "publishedproviderversions"; IBlobContainerRepository blobContainerRepository = new BlobContainerRepository(settings); return(new PublishedFundingUndoBlobStoreRepository(new CommonBlobClient(blobContainerRepository), ctx.GetService <IPublishingResiliencePolicies>(), ctx.GetService <ILogger>())); }); builder.AddSingleton <IPublishedFundingUndoJobCreation, PublishedFundingUndoJobCreation>(); builder.AddSingleton <IPublishedFundingUndoTaskFactoryLocator, PublishedFundingUndoTaskFactoryLocator>(); builder.AddSingleton <IDsgRollBackCosmosDocumentsJob, DsgRollBackCosmosDocumentsJob>(); builder.AddSingleton <IPublishedFundingUndoTaskFactory, DsgRollBackTaskFactory>(); builder.AddSingleton <IRollBackDsg, RollBackDsg>(); return(builder.BuildServiceProvider()); }
public void RegisterComponents(IServiceCollection builder) { builder.AddSingleton <IScenariosRepository, ScenariosRepository>(); builder .AddSingleton <IScenariosService, ScenariosService>() .AddSingleton <IHealthChecker, ScenariosService>(); builder .AddSingleton <IScenariosSearchService, ScenariosSearchService>() .AddSingleton <IHealthChecker, ScenariosSearchService>(); builder .AddSingleton <IValidator <CreateNewTestScenarioVersion>, CreateNewTestScenarioVersionValidator>(); builder .AddSingleton <ISpecificationsRepository, SpecificationsRepository>(); builder .AddSingleton <IBuildProjectRepository, BuildProjectRepository>(); builder .AddSingleton <IDatasetDefinitionFieldChangesProcessor, DatasetDefinitionFieldChangesProcessor>(); builder.AddSingleton <IVersionRepository <TestScenarioVersion>, VersionRepository <TestScenarioVersion> >((ctx) => { CosmosDbSettings scenariosVersioningDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", scenariosVersioningDbSettings); scenariosVersioningDbSettings.CollectionName = "tests"; CosmosRepository resultsRepostory = new CosmosRepository(scenariosVersioningDbSettings); return(new VersionRepository <TestScenarioVersion>(resultsRepostory)); }); builder .AddSingleton <ICalcsRepository, CalcsRepository>(); builder .AddSingleton <ICancellationTokenProvider, HttpContextCancellationProvider>(); builder.AddSingleton <IDatasetRepository, DatasetRepository>(); builder .AddSingleton <IDatasetDefinitionFieldChangesProcessor, DatasetDefinitionFieldChangesProcessor>(); builder.AddUserProviderFromRequest(); builder.AddCalcsInterServiceClient(Configuration); builder.AddSpecificationsInterServiceClient(Configuration); builder.AddDatasetsInterServiceClient(Configuration); builder.AddJobsInterServiceClient(Configuration); builder.AddCosmosDb(Configuration); builder.AddSearch(Configuration); builder.AddServiceBus(Configuration); builder.AddCaching(Configuration); builder.AddFeatureToggling(Configuration); builder.AddApplicationInsights(Configuration, "CalculateFunding.Api.Scenarios"); builder.AddApplicationInsightsTelemetryClient(Configuration, "CalculateFunding.Api.Scenarios"); builder.AddLogging("CalculateFunding.Api.Scenarios"); builder.AddTelemetry(); builder.AddApiKeyMiddlewareSettings((IConfigurationRoot)Configuration); builder.AddHttpContextAccessor(); builder.AddHealthCheckMiddleware(); builder.AddPolicySettings(Configuration); builder.AddSingleton <IScenariosResiliencePolicies>((ctx) => { PolicySettings policySettings = ctx.GetService <PolicySettings>(); BulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); Policy redisPolicy = ResiliencePolicyHelpers.GenerateRedisPolicy(totalNetworkRequestsPolicy); return(new ScenariosResiliencePolicies() { CalcsRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), DatasetRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy) }); }); }
public void RegisterComponents(IServiceCollection builder) { builder.AddHttpCachingMvc(); builder.AddQueryProviderAndExtractorForViewModelMvc < FundingStructure, TemplateMetadataContentsTimedETagProvider, TemplateMatadataContentsTimedETagExtractor>(false); builder.AddSingleton <IFundingStructureService, FundingStructureService>() .AddSingleton <IValidator <UpdateFundingStructureLastModifiedRequest>, UpdateFundingStructureLastModifiedRequestValidator>(); builder.AddSingleton <IUserProfileProvider, UserProfileProvider>(); builder .AddSingleton <IHealthChecker, ControllerResolverHealthCheck>(); builder.AddSingleton <IQueueCreateSpecificationJobActions, QueueCreateSpecificationJobAction>(); builder.AddSingleton <IQueueEditSpecificationJobActions, QueueEditSpecificationJobActions>(); builder.AddSingleton <IQueueDeleteSpecificationJobActions, QueueDeleteSpecificationJobAction>(); builder.AddSingleton <ISpecificationsRepository, SpecificationsRepository>((ctx) => { CosmosDbSettings specsVersioningDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", specsVersioningDbSettings); specsVersioningDbSettings.ContainerName = "specs"; CosmosRepository resultsRepostory = new CosmosRepository(specsVersioningDbSettings); return(new SpecificationsRepository(resultsRepostory)); }); builder .AddSingleton <ISpecificationsService, SpecificationsService>() .AddSingleton <IHealthChecker, SpecificationsService>(); builder.AddSingleton <ISpecificationIndexer, SpecificationIndexer>(); builder.AddSingleton <IProducerConsumerFactory, ProducerConsumerFactory>(); builder.AddSingleton <ISpecificationIndexingService, SpecificationIndexingService>(); builder .AddSingleton <IJobManagement, JobManagement>(); builder.AddSingleton <IValidator <SpecificationCreateModel>, SpecificationCreateModelValidator>(); builder.AddSingleton <IValidator <SpecificationEditModel>, SpecificationEditModelValidator>(); builder.AddSingleton <IValidator <AssignDefinitionRelationshipMessage>, AssignDefinitionRelationshipMessageValidator>(); builder.AddSingleton <IValidator <AssignSpecificationProviderVersionModel>, AssignSpecificationProviderVersionModelValidator>(); builder .AddSingleton <ISpecificationsSearchService, SpecificationsSearchService>() .AddSingleton <IHealthChecker, SpecificationsSearchService>(); builder.AddSingleton <IResultsRepository, ResultsRepository>(); builder .AddSingleton <ISpecificationsReportService, SpecificationsReportService>() .AddSingleton <IHealthChecker, SpecificationsReportService>(); builder.AddSingleton <ITemplateMetadataResolver>((ctx) => { TemplateMetadataResolver resolver = new TemplateMetadataResolver(); TemplateMetadataGenerator schema10Generator = new TemplateMetadataGenerator(ctx.GetService <ILogger>()); resolver.Register("1.0", schema10Generator); return(resolver); }); builder .AddSingleton <LocalIBlobClient, LocalBlobClient>((ctx) => { AzureStorageSettings storageSettings = new AzureStorageSettings(); Configuration.Bind("AzureStorageSettings", storageSettings); storageSettings.ContainerName = "providerversions"; return(new LocalBlobClient(storageSettings)); }); builder.AddSingleton <ISpecificationTemplateVersionChangedHandler, SpecificationTemplateVersionChangedHandler>(); builder .AddSingleton <IBlobClient, BlobClient>((ctx) => { BlobStorageOptions storageSettings = new BlobStorageOptions(); Configuration.Bind("AzureStorageSettings", storageSettings); storageSettings.ContainerName = "providerversions"; IBlobContainerRepository blobContainerRepository = new BlobContainerRepository(storageSettings); return(new BlobClient(blobContainerRepository)); }); builder.AddSingleton <IVersionRepository <Models.Specs.SpecificationVersion>, VersionRepository <Models.Specs.SpecificationVersion> >((ctx) => { CosmosDbSettings specsVersioningDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", specsVersioningDbSettings); specsVersioningDbSettings.ContainerName = "specs"; CosmosRepository resultsRepostory = new CosmosRepository(specsVersioningDbSettings); return(new VersionRepository <Models.Specs.SpecificationVersion>(resultsRepostory, new NewVersionBuilderFactory <SpecificationVersion>())); }); MapperConfiguration mappingConfig = new MapperConfiguration( c => { c.AddProfile <SpecificationsMappingProfile>(); } ); builder.AddFeatureToggling(Configuration); builder.AddSingleton(mappingConfig.CreateMapper()); builder.AddServiceBus(Configuration); builder.AddSearch(Configuration); builder .AddSingleton <ISearchRepository <SpecificationIndex>, SearchRepository <SpecificationIndex> >(); builder.AddCaching(Configuration); builder.AddResultsInterServiceClient(Configuration); builder.AddJobsInterServiceClient(Configuration); builder.AddGraphInterServiceClient(Configuration); builder.AddCalculationsInterServiceClient(Configuration); builder.AddProvidersInterServiceClient(Configuration); builder.AddPoliciesInterServiceClient(Configuration); builder.AddDatasetsInterServiceClient(Configuration); builder.AddPolicySettings(Configuration); PolicySettings policySettings = ServiceCollectionExtensions.GetPolicySettings(Configuration); AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); builder.AddSingleton <ISpecificationsResiliencePolicies>((ctx) => { Polly.AsyncPolicy redisPolicy = ResiliencePolicyHelpers.GenerateRedisPolicy(totalNetworkRequestsPolicy); return(new SpecificationsResiliencePolicies() { JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), PoliciesApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), CalcsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), ProvidersApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), DatasetsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), SpecificationsSearchRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), SpecificationsRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), ResultsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), CacheProvider = ResiliencePolicyHelpers.GenerateRedisPolicy(totalNetworkRequestsPolicy) }); }); builder.AddSingleton <IJobManagementResiliencePolicies>((ctx) => { return(new JobManagementResiliencePolicies() { JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy) }); }); builder.AddApplicationInsightsTelemetry(); builder.AddApplicationInsightsTelemetryClient(Configuration, "CalculateFunding.Apis.Specs"); builder.AddApplicationInsightsServiceName(Configuration, "CalculateFunding.Api.Specs"); builder.AddLogging("CalculateFunding.Apis.Specs"); builder.AddTelemetry(); builder.AddApiKeyMiddlewareSettings((IConfigurationRoot)Configuration); builder.AddHttpContextAccessor(); builder.AddHealthCheckMiddleware(); if (Configuration.IsSwaggerEnabled()) { builder.ConfigureSwaggerServices(title: "Specs Microservice API"); } }
private static IServiceProvider Register(IServiceCollection builder, IConfigurationRoot config) { // These registrations of the functions themselves are just for the DebugQueue. Ideally we don't want these registered in production if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development") { builder.AddScoped <OnPopulateScopedProvidersEventTrigger>(); builder.AddScoped <OnPopulateScopedProvidersEventTriggerFailure>(); builder.AddScoped <OnProviderSnapshotDataLoadEventTrigger>(); builder.AddScoped <OnProviderSnapshotDataLoadEventTriggerFailure>(); builder.AddScoped <OnNewProviderVersionCheck>(); } builder.AddSingleton <IUserProfileProvider, UserProfileProvider>(); builder.AddSingleton <IConfiguration>(config); builder .AddSingleton <IProviderVersionService, ProviderVersionService>() .AddSingleton <IHealthChecker, ProviderVersionService>(); builder .AddSingleton <IProviderSnapshotDataLoadService, ProviderSnapshotDataLoadService>() .AddSingleton <IHealthChecker, ProviderSnapshotDataLoadService>(); builder .AddSingleton <IScopedProvidersService, ScopedProvidersService>() .AddSingleton <IHealthChecker, ScopedProvidersService>(); builder .AddSingleton <IProviderVersionUpdateCheckService, ProviderVersionUpdateCheckService>(); builder .AddSingleton <IProvidersApiClient, ProvidersApiClient>(); builder .AddSingleton <IJobManagement, JobManagement>(); builder.AddJobsInterServiceClient(config, handlerLifetime: Timeout.InfiniteTimeSpan); builder.AddSpecificationsInterServiceClient(config, handlerLifetime: Timeout.InfiniteTimeSpan); builder.AddResultsInterServiceClient(config, handlerLifetime: Timeout.InfiniteTimeSpan); builder.AddFundingDataServiceInterServiceClient(config, handlerLifetime: Timeout.InfiniteTimeSpan); builder.AddPoliciesInterServiceClient(config, handlerLifetime: Timeout.InfiniteTimeSpan); builder.AddSingleton <IDeadletterService, DeadletterService>(); builder.AddCaching(config); builder.AddApplicationInsightsTelemetryClient(config, "CalculateFunding.Functions.Providers"); builder.AddApplicationInsightsServiceName(config, "CalculateFunding.Functions.Providers"); builder.AddLogging("CalculateFunding.Functions.Providers"); builder.AddTelemetry(); builder.AddFeatureToggling(config); MapperConfiguration providerVersionsConfig = new MapperConfiguration(c => { c.AddProfile <ProviderVersionsMappingProfile>(); }); builder .AddSingleton(providerVersionsConfig.CreateMapper()); builder .AddSingleton <IFileSystemCache, FileSystemCache>() .AddSingleton <IFileSystemAccess, FileSystemAccess>() .AddSingleton <IFileSystemCacheSettings, FileSystemCacheSettings>(); builder.AddSearch(config); builder .AddSingleton <ISearchRepository <ProvidersIndex>, SearchRepository <ProvidersIndex> >(); builder .AddSingleton <IProviderVersionServiceSettings>(ctx => { ProviderVersionServiceSettings settings = new ProviderVersionServiceSettings(); config.Bind("providerversionservicesettings", settings); return(settings); }); builder .AddSingleton <IScopedProvidersServiceSettings>(ctx => { ScopedProvidersServiceSettings settings = new ScopedProvidersServiceSettings(); config.Bind("scopedprovidersservicesetting", settings); return(settings); }); PolicySettings policySettings = ServiceCollectionExtensions.GetPolicySettings(config); AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); ProvidersResiliencePolicies resiliencePolicies = CreateResiliencePolicies(totalNetworkRequestsPolicy); builder.AddSingleton <IJobManagementResiliencePolicies>(resiliencePolicies); builder.AddSingleton <IProvidersResiliencePolicies>(resiliencePolicies); builder.AddSingleton <IValidator <ProviderVersionViewModel>, UploadProviderVersionValidator>(); builder .AddSingleton <IBlobClient, BlobClient>((ctx) => { AzureStorageSettings storageSettings = new AzureStorageSettings(); config.Bind("AzureStorageSettings", storageSettings); storageSettings.ContainerName = "providerversions"; return(new BlobClient(storageSettings)); }); builder.AddSingleton <IProviderVersionsMetadataRepository, ProviderVersionsMetadataRepository>( ctx => { CosmosDbSettings specRepoDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", specRepoDbSettings); specRepoDbSettings.ContainerName = "providerversionsmetadata"; CosmosRepository cosmosRepository = new CosmosRepository(specRepoDbSettings); return(new ProviderVersionsMetadataRepository(cosmosRepository)); }); builder.AddServiceBus(config, "providers"); builder.AddScoped <IUserProfileProvider, UserProfileProvider>(); return(builder.BuildServiceProvider()); }
public void RegisterComponents(IServiceCollection builder) { builder.AddSingleton <IUserProfileProvider, UserProfileProvider>(); builder .AddSingleton <IHealthChecker, ControllerResolverHealthCheck>(); builder.AddSingleton <IScenariosRepository, ScenariosRepository>((ctx) => { CosmosDbSettings scenariosVersioningDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", scenariosVersioningDbSettings); scenariosVersioningDbSettings.ContainerName = "tests"; CosmosRepository resultsRepostory = new CosmosRepository(scenariosVersioningDbSettings); return(new ScenariosRepository(resultsRepostory)); }); builder .AddSingleton <IScenariosService, ScenariosService>() .AddSingleton <IHealthChecker, ScenariosService>(); builder .AddSingleton <IScenariosSearchService, ScenariosSearchService>() .AddSingleton <IHealthChecker, ScenariosSearchService>(); builder.AddSingleton <IJobManagement, JobManagement>(); builder .AddSingleton <IValidator <CreateNewTestScenarioVersion>, CreateNewTestScenarioVersionValidator>(); builder .AddSingleton <IDatasetDefinitionFieldChangesProcessor, DatasetDefinitionFieldChangesProcessor>(); builder.AddSingleton <IVersionRepository <TestScenarioVersion>, VersionRepository <TestScenarioVersion> >((ctx) => { CosmosDbSettings scenariosVersioningDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", scenariosVersioningDbSettings); scenariosVersioningDbSettings.ContainerName = "tests"; CosmosRepository resultsRepostory = new CosmosRepository(scenariosVersioningDbSettings); return(new VersionRepository <TestScenarioVersion>(resultsRepostory, new NewVersionBuilderFactory <TestScenarioVersion>())); }); builder .AddSingleton <ICalcsRepository, CalcsRepository>(); builder .AddSingleton <ICancellationTokenProvider, HttpContextCancellationProvider>(); builder .AddSingleton <IDatasetDefinitionFieldChangesProcessor, DatasetDefinitionFieldChangesProcessor>(); MapperConfiguration scenariosConfig = new MapperConfiguration(c => { c.AddProfile <DatasetsMappingProfile>(); }); builder .AddSingleton(scenariosConfig.CreateMapper()); builder.AddCalculationsInterServiceClient(Configuration); builder.AddSpecificationsInterServiceClient(Configuration); builder.AddDatasetsInterServiceClient(Configuration); builder.AddJobsInterServiceClient(Configuration); builder.AddSearch(Configuration); builder .AddSingleton <ISearchRepository <ScenarioIndex>, SearchRepository <ScenarioIndex> >(); builder .AddSingleton <ISearchRepository <TestScenarioResultIndex>, SearchRepository <TestScenarioResultIndex> >(); builder.AddServiceBus(Configuration); builder.AddCaching(Configuration); builder.AddFeatureToggling(Configuration); builder.AddApplicationInsightsTelemetry(); builder.AddApplicationInsightsTelemetryClient(Configuration, "CalculateFunding.Api.Scenarios"); builder.AddApplicationInsightsServiceName(Configuration, "CalculateFunding.Api.Scenarios"); builder.AddLogging("CalculateFunding.Api.Scenarios"); builder.AddTelemetry(); builder.AddApiKeyMiddlewareSettings((IConfigurationRoot)Configuration); builder.AddHttpContextAccessor(); builder.AddHealthCheckMiddleware(); builder.AddPolicySettings(Configuration); builder.AddSingleton <IScenariosResiliencePolicies>((ctx) => { PolicySettings policySettings = ctx.GetService <PolicySettings>(); AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); AsyncPolicy redisPolicy = ResiliencePolicyHelpers.GenerateRedisPolicy(totalNetworkRequestsPolicy); return(new ScenariosResiliencePolicies() { CalcsRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), DatasetsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), ScenariosRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), SpecificationsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), ScenariosApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), }); }); builder.AddSingleton <IJobManagementResiliencePolicies>((ctx) => { PolicySettings policySettings = ctx.GetService <PolicySettings>(); AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); return(new JobManagementResiliencePolicies() { JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), }); }); if (Configuration.IsSwaggerEnabled()) { builder.ConfigureSwaggerServices(title: "Scenarios Microservice API"); } }
public void RegisterComponents(IServiceCollection builder) { builder.AddSingleton <IUserProfileProvider, UserProfileProvider>(); builder .AddSingleton <IHealthChecker, ControllerResolverHealthCheck>(); builder.AddSingleton <ICosmosRepository, CosmosRepository>(); builder.AddSingleton <ICosmosDbScalingService, CosmosDbScalingService>(); builder.AddSingleton <ICosmosDbScalingRepositoryProvider, CosmosDbScalingRepositoryProvider>(); builder.AddSingleton <ICosmosDbScalingRequestModelBuilder, CosmosDbScalingRequestModelBuilder>(); builder.AddSingleton <ICosmosDbThrottledEventsFilter, CosmosDbThrottledEventsFilter>(); builder.AddSingleton <IValidator <ScalingConfigurationUpdateModel>, ScalingConfigurationUpdateModelValidator>(); builder.AddSingleton <ICosmosDbScalingConfigRepository>((ctx) => { CosmosDbSettings cosmosDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", cosmosDbSettings); cosmosDbSettings.ContainerName = "cosmosscalingconfig"; CosmosRepository cosmosRepository = new CosmosRepository(cosmosDbSettings); return(new CosmosDbScalingConfigRepository(cosmosRepository)); }); builder.AddSingleton <IJobManagement, JobManagement>(); builder.AddFeatureToggling(Configuration); builder.AddServiceBus(Configuration); builder.AddSearch(Configuration); builder.AddCaching(Configuration); builder.AddJobsInterServiceClient(Configuration); builder.AddPolicySettings(Configuration); builder.AddSingleton <ICosmosDbScalingResiliencePolicies>(m => { PolicySettings policySettings = ServiceCollectionExtensions.GetPolicySettings(Configuration); AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); CosmosDbScalingResiliencePolicies resiliencePolicies = new CosmosDbScalingResiliencePolicies() { ScalingRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), ScalingConfigRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), CacheProvider = ResiliencePolicyHelpers.GenerateRedisPolicy(totalNetworkRequestsPolicy) }; return(resiliencePolicies); }); builder.AddSingleton <IJobManagementResiliencePolicies>((ctx) => { PolicySettings policySettings = ServiceCollectionExtensions.GetPolicySettings(Configuration); AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); return(new JobManagementResiliencePolicies() { JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), }); }); builder.AddApplicationInsightsTelemetry(); builder.AddApplicationInsightsTelemetryClient(Configuration, "CalculateFunding.Apis.CosmosDbScaling"); builder.AddApplicationInsightsServiceName(Configuration, "CalculateFunding.Api.CosmosDbScaling"); builder.AddLogging("CalculateFunding.Apis.CosmosDbScaling"); builder.AddTelemetry(); builder.AddApiKeyMiddlewareSettings((IConfigurationRoot)Configuration); builder.AddHttpContextAccessor(); builder.AddHealthCheckMiddleware(); if (Configuration.IsSwaggerEnabled()) { builder.ConfigureSwaggerServices(title: "CosmosDbScaling Microservice API", version: "v1"); } }
private static IServiceProvider Register(IServiceCollection builder, IConfigurationRoot config) { builder .AddSingleton <OnTestSpecificationProviderResultsCleanup>(); builder .AddSingleton <OnEditSpecificationEvent>(); builder .AddSingleton <OnTestExecution>(); builder .AddSingleton <IBuildProjectRepository, BuildProjectRepository>(); builder .AddSingleton <IGherkinParserService, GherkinParserService>(); builder .AddSingleton <IGherkinParser, GherkinParser>(); builder .AddSingleton <ICodeMetadataGeneratorService, ReflectionCodeMetadataGenerator>(); builder .AddSingleton <IStepParserFactory, StepParserFactory>(); builder .AddSingleton <ITestResultsRepository, TestResultsRepository>(); builder .AddSingleton <ISpecificationRepository, SpecificationRepository>(); builder .AddSingleton <IScenariosRepository, ScenariosRepository>(); builder .AddSingleton <ITestEngineService, Services.TestRunner.Services.TestEngineService>(); builder .AddSingleton <ITestEngine, Services.TestRunner.TestEngine>(); builder .AddSingleton <IGherkinExecutor, GherkinExecutor>(); builder .AddSingleton <ICalculationsRepository, CalculationsRepository>(); builder.AddSingleton <IProviderService, ProviderService>(); builder.AddSingleton <ICosmosRepository, CosmosRepository>(); builder.AddSingleton <IProviderSourceDatasetsRepository, ProviderSourceDatasetsRepository>((ctx) => { CosmosDbSettings providersDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", providersDbSettings); providersDbSettings.CollectionName = "providerdatasets"; CosmosRepository providersCosmosRepostory = new CosmosRepository(providersDbSettings); EngineSettings engineSettings = ctx.GetService <EngineSettings>(); return(new ProviderSourceDatasetsRepository(providersCosmosRepostory, engineSettings)); }); builder.AddSingleton <IProviderResultsRepository, ProviderResultsRepository>((ctx) => { CosmosDbSettings providersDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", providersDbSettings); providersDbSettings.CollectionName = "calculationresults"; CosmosRepository providersCosmosRepostory = new CosmosRepository(providersDbSettings); ICacheProvider cacheProvider = ctx.GetService <ICacheProvider>(); return(new ProviderResultsRepository(providersCosmosRepostory)); }); builder.AddSingleton <ITestResultsSearchService, TestResultsSearchService>(); builder.AddSingleton <ITestResultsCountsService, TestResultsCountsService>(); MapperConfiguration resultsMappingConfiguration = new MapperConfiguration(c => { c.AddProfile <ResultsMappingProfile>(); c.AddProfile <ProviderMappingProfile>(); }); builder .AddSingleton(resultsMappingConfiguration.CreateMapper()); builder.AddSingleton <ITestResultsService, TestResultsService>(); if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development") { builder.AddCosmosDb(config, "testresults"); } else { builder.AddCosmosDb(config); } builder.AddSearch(config); builder.AddSpecificationsInterServiceClient(config); builder.AddScenariosInterServiceClient(config); builder.AddCalcsInterServiceClient(config); builder.AddResultsInterServiceClient(config); builder.AddCaching(config); builder.AddApplicationInsights(config, "CalculateFunding.Functions.TestEngine"); builder.AddApplicationInsightsTelemetryClient(config, "CalculateFunding.Functions.TestEngine", TelemetryChannelType.Sync); builder.AddLogging("CalculateFunding.Functions.TestEngine"); builder.AddTelemetry(); builder.AddEngineSettings(config); builder.AddPolicySettings(config); builder.AddFeatureToggling(config); builder.AddSingleton <ITestRunnerResiliencePolicies>((ctx) => { PolicySettings policySettings = ctx.GetService <PolicySettings>(); BulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); Policy redisPolicy = ResiliencePolicyHelpers.GenerateRedisPolicy(totalNetworkRequestsPolicy); ResiliencePolicies resiliencePolicies = new ResiliencePolicies() { BuildProjectRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), CacheProviderRepository = redisPolicy, ProviderResultsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), ProviderSourceDatasetsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), ScenariosRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(new[] { totalNetworkRequestsPolicy, redisPolicy }), SpecificationRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), TestResultsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), TestResultsSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy) }; return(resiliencePolicies); }); return(builder.BuildServiceProvider()); }
public void RegisterComponents(IServiceCollection builder) { builder.AddSingleton <ICalculationResultsRepository, CalculationResultsRepository>(); builder .AddSingleton <IResultsService, ResultsService>() .AddSingleton <IHealthChecker, ResultsService>(); builder .AddSingleton <IPublishedResultsService, PublishedResultsService>() .AddSingleton <IHealthChecker, PublishedResultsService>(); builder .AddSingleton <IResultsSearchService, ResultsSearchService>() .AddSingleton <IHealthChecker, ResultsSearchService>(); builder .AddSingleton <IProviderCalculationResultsSearchService, ProviderCalculationResultsSearchService>() .AddSingleton <IHealthChecker, ProviderCalculationResultsSearchService>(); builder .AddSingleton <ICalculationProviderResultsSearchService, CalculationProviderResultsSearchService>() .AddSingleton <IHealthChecker, CalculationProviderResultsSearchService>(); builder.AddSingleton <IProviderImportMappingService, ProviderImportMappingService>(); builder .AddSingleton <IAllocationNotificationsFeedsSearchService, AllocationNotificationsFeedsSearchService>(); builder.AddSingleton <IProviderVariationAssemblerService, ProviderVariationAssemblerService>(); MapperConfiguration resultsConfig = new MapperConfiguration(c => { c.AddProfile <DatasetsMappingProfile>(); c.AddProfile <ResultServiceMappingProfile>(); }); builder .AddSingleton(resultsConfig.CreateMapper()); builder.AddSingleton <ICalculationResultsRepository, CalculationResultsRepository>((ctx) => { CosmosDbSettings calssDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", calssDbSettings); calssDbSettings.CollectionName = "calculationresults"; CosmosRepository calcsCosmosRepostory = new CosmosRepository(calssDbSettings); return(new CalculationResultsRepository(calcsCosmosRepostory)); }); builder.AddSingleton <IProviderSourceDatasetRepository, ProviderSourceDatasetRepository>((ctx) => { CosmosDbSettings provDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", provDbSettings); provDbSettings.CollectionName = "providerdatasets"; CosmosRepository calcsCosmosRepostory = new CosmosRepository(provDbSettings); return(new ProviderSourceDatasetRepository(calcsCosmosRepostory)); }); builder.AddSingleton <IPublishedProviderResultsRepository, PublishedProviderResultsRepository>((ctx) => { CosmosDbSettings resultsDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", resultsDbSettings); resultsDbSettings.CollectionName = "publishedproviderresults"; CosmosRepository resultsRepostory = new CosmosRepository(resultsDbSettings); return(new PublishedProviderResultsRepository(resultsRepostory)); }); builder.AddSingleton <IProviderChangesRepository, ProviderChangesRepository>((ctx) => { CosmosDbSettings resultsDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", resultsDbSettings); resultsDbSettings.CollectionName = "publishedproviderchanges"; CosmosRepository resultsRepostory = new CosmosRepository(resultsDbSettings); ILogger logger = ctx.GetService <ILogger>(); return(new ProviderChangesRepository(resultsRepostory, logger)); }); builder.AddSingleton <IProviderCalculationResultsReIndexerService, ProviderCalculationResultsReIndexerService>(); builder.AddSingleton <IValidator <MasterProviderModel>, MasterProviderModelValidator>(); builder .AddSingleton <ISpecificationsRepository, SpecificationsRepository>(); builder .AddSingleton <ICalculationsRepository, CalculationsRepository>(); builder .AddSingleton <IPublishedProviderResultsAssemblerService, PublishedProviderResultsAssemblerService>(); builder.AddSingleton <IPublishedProviderResultsSettings, PublishedProviderResultsSettings>((ctx) => { PublishedProviderResultsSettings settings = new PublishedProviderResultsSettings(); Configuration.Bind("PublishedProviderResultsSettings", settings); return(settings); }); builder.AddSingleton <IVersionRepository <PublishedAllocationLineResultVersion>, VersionRepository <PublishedAllocationLineResultVersion> >((ctx) => { CosmosDbSettings versioningDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", versioningDbSettings); versioningDbSettings.CollectionName = "publishedproviderresults"; CosmosRepository resultsRepostory = new CosmosRepository(versioningDbSettings); return(new VersionRepository <PublishedAllocationLineResultVersion>(resultsRepostory)); }); builder .AddSingleton <IBlobClient, BlobClient>((ctx) => { AzureStorageSettings storageSettings = new AzureStorageSettings(); Configuration.Bind("AzureStorageSettings", storageSettings); storageSettings.ContainerName = "datasets"; return(new BlobClient(storageSettings)); }); builder.AddUserProviderFromRequest(); builder.AddSearch(Configuration); builder.AddServiceBus(Configuration); builder.AddCaching(Configuration); builder.AddApplicationInsights(Configuration, "CalculateFunding.Api.Results"); builder.AddApplicationInsightsTelemetryClient(Configuration, "CalculateFunding.Api.Results"); builder.AddLogging("CalculateFunding.Api.Results"); builder.AddTelemetry(); builder.AddSpecificationsInterServiceClient(Configuration); builder.AddCalcsInterServiceClient(Configuration); builder.AddJobsInterServiceClient(Configuration); builder.AddPolicySettings(Configuration); builder.AddHttpContextAccessor(); builder.AddFeatureToggling(Configuration); builder.AddSingleton <IPublishedAllocationLineLogicalResultVersionService, PublishedAllocationLineLogicalResultVersionService>(); builder.AddSingleton <IResultsResiliencePolicies>((ctx) => { PolicySettings policySettings = ctx.GetService <PolicySettings>(); BulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); return(new ResiliencePolicies() { CalculationProviderResultsSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy), ResultsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), ResultsSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy), SpecificationsRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), AllocationNotificationFeedSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy), ProviderProfilingRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), PublishedProviderCalculationResultsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), PublishedProviderResultsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), CalculationsRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), ProviderChangesRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), ProviderCalculationResultsSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy), CsvBlobPolicy = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), }); }); builder.AddApiKeyMiddlewareSettings((IConfigurationRoot)Configuration); builder.AddHealthCheckMiddleware(); ServiceProvider = builder.BuildServiceProvider(); }
public void RegisterComponents(IServiceCollection builder) { builder.AddSingleton <IUserProfileProvider, UserProfileProvider>(); builder .AddSingleton <IHealthChecker, ControllerResolverHealthCheck>(); builder.AddApiKeyMiddlewareSettings((IConfigurationRoot)Configuration); builder .AddSingleton <IUserService, UserService>() .AddSingleton <IHealthChecker, UserService>(); builder .AddSingleton <IFundingStreamPermissionService, FundingStreamPermissionService>() .AddSingleton <IHealthChecker, FundingStreamPermissionService>(); builder.AddSingleton <IValidator <UserCreateModel>, UserCreateModelValidator>(); builder.AddSingleton <IUserRepository, UserRepository>((ctx) => { CosmosDbSettings usersDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", usersDbSettings); usersDbSettings.ContainerName = "users"; CosmosRepository usersCosmosRepostory = new CosmosRepository(usersDbSettings); return(new UserRepository(usersCosmosRepostory)); }); MapperConfiguration mappingConfig = new MapperConfiguration(c => c.AddProfile <UsersMappingProfile>()); builder.AddSingleton(mappingConfig.CreateMapper()); builder.AddSingleton <IVersionRepository <FundingStreamPermissionVersion>, VersionRepository <FundingStreamPermissionVersion> >((ctx) => { CosmosDbSettings versioningDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", versioningDbSettings); versioningDbSettings.ContainerName = "users"; CosmosRepository versioningRepository = new CosmosRepository(versioningDbSettings); return(new VersionRepository <FundingStreamPermissionVersion>(versioningRepository, new NewVersionBuilderFactory <FundingStreamPermissionVersion>())); }); builder.AddPolicySettings(Configuration); builder.AddSingleton <IUsersResiliencePolicies>((ctx) => { PolicySettings policySettings = ctx.GetService <PolicySettings>(); AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); return(new UsersResiliencePolicies { FundingStreamPermissionVersionRepositoryPolicy = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), CacheProviderPolicy = ResiliencePolicyHelpers.GenerateRedisPolicy(totalNetworkRequestsPolicy), SpecificationApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), UserRepositoryPolicy = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), }); }); builder.AddCaching(Configuration); builder.AddApplicationInsightsTelemetry(); builder.AddApplicationInsightsTelemetryClient(Configuration, "CalculateFunding.Api.Users"); builder.AddApplicationInsightsServiceName(Configuration, "CalculateFunding.Api.Users"); builder.AddLogging("CalculateFunding.Api.Users"); builder.AddTelemetry(); builder.AddHttpContextAccessor(); builder.AddHealthCheckMiddleware(); builder.AddSpecificationsInterServiceClient(Configuration); if (Configuration.IsSwaggerEnabled()) { builder.ConfigureSwaggerServices(title: "Users Microservice API"); } }
public void RegisterComponents(IServiceCollection builder) { builder.AddFeatureToggling(Configuration); // Register v1 services builder .AddSingleton <V1.Interfaces.IAllocationNotificationFeedsService, V1.Services.AllocationNotificationFeedsService>(); builder .AddSingleton <V1.Interfaces.IProviderResultsService, V1.Services.ProviderResultsService>(); builder .AddSingleton <V1.Interfaces.IAllocationsService, V1.Services.AllocationsService>(); builder .AddSingleton <V1.Interfaces.ITimePeriodsService, V1.Services.TimePeriodsService>(); builder .AddSingleton <V1.Interfaces.IFundingStreamService, V1.Services.FundingStreamService>(); // Register v2 services builder .AddSingleton <V2.Interfaces.IAllocationNotificationFeedsService, V2.Services.AllocationNotificationFeedsService>(); builder .AddSingleton <V2.Interfaces.IProviderResultsService, V2.Services.ProviderResultsService>(); builder .AddSingleton <V2.Interfaces.IAllocationsService, V2.Services.AllocationsService>(); builder .AddSingleton <V2.Interfaces.ITimePeriodsService, V2.Services.TimePeriodsService>(); builder .AddSingleton <V2.Interfaces.IFundingStreamService, V2.Services.FundingStreamService>(); // Register dependencies builder .AddSingleton <IAllocationNotificationsFeedsSearchService, AllocationNotificationsFeedsSearchService>() .AddSingleton <IHealthChecker, AllocationNotificationsFeedsSearchService>(); builder .AddSingleton <ICalculationResultsRepository, CalculationResultsRepository>(); builder .AddSingleton <IPublishedResultsService, PublishedResultsService>() .AddSingleton <IHealthChecker, PublishedResultsService>(); builder .AddSingleton <ICalculationProviderResultsSearchService, CalculationProviderResultsSearchService>() .AddSingleton <IHealthChecker, CalculationProviderResultsSearchService>(); builder.AddSingleton <IProviderImportMappingService, ProviderImportMappingService>(); builder .AddSingleton <IAllocationNotificationsFeedsSearchService, AllocationNotificationsFeedsSearchService>(); MapperConfiguration resultsConfig = new MapperConfiguration(c => { c.AddProfile <DatasetsMappingProfile>(); c.AddProfile <ExternalApiMappingProfile>(); }); builder .AddSingleton(resultsConfig.CreateMapper()); builder.AddSingleton <IVersionRepository <SpecificationVersion>, VersionRepository <SpecificationVersion> >((ctx) => { CosmosDbSettings specsVersioningDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", specsVersioningDbSettings); specsVersioningDbSettings.CollectionName = "specs"; CosmosRepository resultsRepostory = new CosmosRepository(specsVersioningDbSettings); return(new VersionRepository <SpecificationVersion>(resultsRepostory)); }); builder.AddSingleton <ICalculationResultsRepository, CalculationResultsRepository>((ctx) => { CosmosDbSettings calssDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", calssDbSettings); calssDbSettings.CollectionName = "calculationresults"; CosmosRepository calcsCosmosRepostory = new CosmosRepository(calssDbSettings); return(new CalculationResultsRepository(calcsCosmosRepostory)); }); builder.AddSingleton <IProviderSourceDatasetRepository, ProviderSourceDatasetRepository>((ctx) => { CosmosDbSettings provDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", provDbSettings); provDbSettings.CollectionName = "providerdatasets"; CosmosRepository calcsCosmosRepostory = new CosmosRepository(provDbSettings); return(new ProviderSourceDatasetRepository(calcsCosmosRepostory)); }); builder.AddSingleton <IPublishedProviderResultsRepository, PublishedProviderResultsRepository>((ctx) => { CosmosDbSettings resultsDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", resultsDbSettings); resultsDbSettings.CollectionName = "publishedproviderresults"; CosmosRepository resultsRepostory = new CosmosRepository(resultsDbSettings); return(new PublishedProviderResultsRepository(resultsRepostory)); }); builder.AddSingleton <IProviderChangesRepository, ProviderChangesRepository>((ctx) => { CosmosDbSettings repoSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", repoSettings); repoSettings.CollectionName = "publishedproviderchanges"; CosmosRepository repo = new CosmosRepository(repoSettings); ILogger logger = ctx.GetRequiredService <ILogger>(); return(new ProviderChangesRepository(repo, logger)); }); builder .AddSingleton <ISpecificationsRepository, SpecificationsRepository>(); builder .AddSingleton <IPublishedProviderResultsAssemblerService, PublishedProviderResultsAssemblerService>(); builder.AddSingleton <Services.Specs.Interfaces.ISpecificationsRepository, Services.Specs.SpecificationsRepository>( ctx => { CosmosDbSettings specRepoDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", specRepoDbSettings); specRepoDbSettings.CollectionName = "specs"; CosmosRepository cosmosRepository = new CosmosRepository(specRepoDbSettings); return(new Services.Specs.SpecificationsRepository(cosmosRepository)); }); builder.AddSingleton <IVersionRepository <PublishedAllocationLineResultVersion>, VersionRepository <PublishedAllocationLineResultVersion> >((ctx) => { CosmosDbSettings versioningDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", versioningDbSettings); versioningDbSettings.CollectionName = "publishedproviderresults"; CosmosRepository resultsRepostory = new CosmosRepository(versioningDbSettings); return(new VersionRepository <PublishedAllocationLineResultVersion>(resultsRepostory)); }); builder.AddSingleton <IPublishedAllocationLineLogicalResultVersionService, PublishedAllocationLineLogicalResultVersionService>(); builder.AddSingleton <IPublishedProviderResultsSettings, PublishedProviderResultsSettings>((ctx) => { PublishedProviderResultsSettings settings = new PublishedProviderResultsSettings(); Configuration.Bind("PublishedProviderResultsSettings", settings); return(settings); }); builder.AddSingleton <IFundingService, FundingService>(); builder.AddSingleton <IValidator <PolicyCreateModel>, PolicyCreateModelValidator>(); builder.AddSingleton <IValidator <SpecificationCreateModel>, SpecificationCreateModelValidator>(); builder.AddSingleton <IValidator <CalculationCreateModel>, CalculationCreateModelValidator>(); builder.AddSingleton <IValidator <AssignDefinitionRelationshipMessage>, AssignDefinitionRelationshipMessageValidator>(); builder.AddSingleton <IValidator <SpecificationEditModel>, SpecificationEditModelValidator>(); builder.AddSingleton <IValidator <PolicyEditModel>, PolicyEditModelValidator>(); builder.AddSingleton <IValidator <CalculationEditModel>, CalculationEditModelValidator>(); builder.AddSingleton <IResultsRepository, ResultsRepository>(); builder.AddResultsInterServiceClient(Configuration); builder.AddUserProviderFromRequest(); builder.AddSearch(Configuration); builder.AddServiceBus(Configuration); builder.AddCaching(Configuration); builder.AddApplicationInsights(Configuration, "CalculateFunding.Api.External"); builder.AddApplicationInsightsTelemetryClient(Configuration, "CalculateFunding.Api.External"); builder.AddLogging("CalculateFunding.Api.External"); builder.AddTelemetry(); builder.AddSpecificationsInterServiceClient(Configuration); builder.AddPolicySettings(Configuration); builder.AddHttpContextAccessor(); builder.AddJobsInterServiceClient(Configuration); builder.AddSingleton <IResultsResiliencePolicies>((ctx) => { PolicySettings policySettings = ctx.GetService <PolicySettings>(); BulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); return(new ResiliencePolicies() { CalculationProviderResultsSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy), ResultsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), ResultsSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy), SpecificationsRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), AllocationNotificationFeedSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy), ProviderProfilingRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), PublishedProviderCalculationResultsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), PublishedProviderResultsRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), CalculationsRepository = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), ProviderCalculationResultsSearchRepository = SearchResiliencePolicyHelper.GenerateSearchPolicy(totalNetworkRequestsPolicy), ProviderChangesRepository = CosmosResiliencePolicyHelper.GenerateCosmosPolicy(totalNetworkRequestsPolicy), CsvBlobPolicy = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy), }); }); builder.AddHealthCheckMiddleware(); builder.AddTransient <ContentTypeCheckMiddleware>(); ServiceProvider = builder.BuildServiceProvider(); }
private static IServiceProvider Register(IServiceCollection builder, IConfigurationRoot config) { // These registrations of the functions themselves are just for the DebugQueue. Ideally we don't want these registered in production if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development") { builder.AddScoped <OnProviderResultsSpecificationCleanup>(); builder.AddScoped <OnReIndexCalculationResults>(); builder.AddScoped <OnCalculationResultsCsvGeneration>(); builder.AddScoped <OnCalculationResultsCsvGenerationTimer>(); builder.AddScoped <OnMergeSpecificationInformationForProviderWithResults>(); builder.AddScoped <OnMergeSpecificationInformationForProviderWithResultsFailure>(); builder.AddScoped <OnDeleteCalculationResults>(); builder.AddScoped <OnDeleteCalculationResultsFailure>(); builder.AddScoped <OnSearchIndexWriterEventTrigger>(); builder.AddScoped <OnSearchIndexWriterEventTriggerFailure>(); } builder.AddSingleton <IUserProfileProvider, UserProfileProvider>(); builder.AddSingleton <ISpecificationsWithProviderResultsService, SpecificationsWithProviderResultsService>(); builder.AddSingleton <IProducerConsumerFactory, ProducerConsumerFactory>(); builder.AddSingleton <IConfiguration>(config); builder.AddSingleton <ICalculationResultsRepository, CalculationResultsRepository>(); builder.AddSingleton <IResultsService, ResultsService>(); builder.AddSingleton <IJobManagement, JobManagement>(); builder.AddSingleton <ICalculationsRepository, CalculationsRepository>(); builder.AddSingleton <IDeadletterService, DeadletterService>(); builder.AddSingleton <IProviderCalculationResultsReIndexerService, ProviderCalculationResultsReIndexerService>(); builder.AddTransient <ICsvUtils, CsvUtils>(); builder .AddTransient <IProviderResultsCsvGeneratorService, ProviderResultsCsvGeneratorService>() .AddTransient <IHealthChecker, ProviderResultsCsvGeneratorService>(); builder.AddTransient <IProviderResultsToCsvRowsTransformation, ProviderResultsToCsvRowsTransformation>(); builder.AddSingleton <IFileSystemAccess, FileSystemAccess>(); builder.AddSingleton <IFileSystemCacheSettings, FileSystemCacheSettings>(); builder .AddSingleton <ISearchIndexWriterSettings, SearchIndexWriterSettings>((ctx) => { IConfigurationSection setttingConfig = config.GetSection("searchIndexWriterSettings"); return(new SearchIndexWriterSettings(setttingConfig)); }); builder.AddSingleton <CommonStorage.IBlobClient>(ctx => { CommonStorage.BlobStorageOptions options = new CommonStorage.BlobStorageOptions(); config.Bind("AzureStorageSettings", options); options.ContainerName = "calcresults"; CommonStorage.IBlobContainerRepository blobContainerRepository = new CommonStorage.BlobContainerRepository(options); return(new CommonStorage.BlobClient(blobContainerRepository)); }); builder.AddScoped <ISearchIndexProcessorFactory, SearchIndexProcessorFactory>(); builder.AddScoped <ISearchIndexDataReader <ProviderResultDataKey, ProviderResult>, ProviderCalculationResultsIndexDataReader>(); builder.AddScoped <ISearchIndexTrasformer <ProviderResult, ProviderCalculationResultsIndex>, ProviderCalculationResultsIndexTransformer>(); builder.AddScoped <ISearchIndexProcessor, ProviderCalculationResultsIndexProcessor>(); builder.AddScoped <ISearchIndexWriterService, SearchIndexWriterService>(); builder.AddCaching(config); builder.AddSingleton <ICalculationResultsRepository, CalculationResultsRepository>((ctx) => { CosmosDbSettings calssDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", calssDbSettings); calssDbSettings.ContainerName = "calculationresults"; CosmosRepository calcsCosmosRepostory = new CosmosRepository(calssDbSettings); EngineSettings engineSettings = ctx.GetService <EngineSettings>(); return(new CalculationResultsRepository(calcsCosmosRepostory, engineSettings)); }); builder.AddSingleton <IProviderSourceDatasetRepository, ProviderSourceDatasetRepository>((ctx) => { CosmosDbSettings provDbSettings = new CosmosDbSettings(); config.Bind("CosmosDbSettings", provDbSettings); provDbSettings.ContainerName = "providerdatasets"; CosmosRepository calcsCosmosRepostory = new CosmosRepository(provDbSettings); return(new ProviderSourceDatasetRepository(calcsCosmosRepostory)); }); builder .AddSingleton <IBlobClient, AzureStorage.BlobClient>((ctx) => { AzureStorageSettings storageSettings = new AzureStorageSettings(); config.Bind("AzureStorageSettings", storageSettings); storageSettings.ContainerName = "calcresults"; return(new AzureStorage.BlobClient(storageSettings)); }); builder.AddSearch(config); builder .AddSingleton <ISearchRepository <ProviderCalculationResultsIndex>, SearchRepository <ProviderCalculationResultsIndex> >(); builder.AddServiceBus(config, "results"); builder.AddCaching(config); builder.AddApplicationInsightsTelemetryClient(config, "CalculateFunding.Functions.Results"); builder.AddApplicationInsightsServiceName(config, "CalculateFunding.Functions.Results"); builder.AddLogging("CalculateFunding.Functions.Results"); builder.AddTelemetry(); builder.AddEngineSettings(config); builder.AddCalculationsInterServiceClient(config, handlerLifetime: Timeout.InfiniteTimeSpan); builder.AddSpecificationsInterServiceClient(config, handlerLifetime: Timeout.InfiniteTimeSpan); builder.AddJobsInterServiceClient(config, handlerLifetime: Timeout.InfiniteTimeSpan); builder.AddProvidersInterServiceClient(config, handlerLifetime: Timeout.InfiniteTimeSpan); builder.AddPoliciesInterServiceClient(config, handlerLifetime: Timeout.InfiniteTimeSpan); MapperConfiguration resultsConfig = new MapperConfiguration(c => { c.AddProfile <ResultsMappingProfile>(); }); builder.AddSingleton(resultsConfig.CreateMapper()); builder.AddFeatureToggling(config); builder.AddSingleton <ICancellationTokenProvider, InactiveCancellationTokenProvider>(); PolicySettings policySettings = ServiceCollectionExtensions.GetPolicySettings(config); ResiliencePolicies resultsResiliencePolicies = CreateResiliencePolicies(policySettings); builder.AddSingleton <IResultsResiliencePolicies>(resultsResiliencePolicies); builder.AddSingleton <IJobManagementResiliencePolicies>((ctx) => { AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); return(new JobManagementResiliencePolicies() { JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy) }); }); builder.AddScoped <IUserProfileProvider, UserProfileProvider>(); return(builder.BuildServiceProvider()); }
public void RegisterComponents(IServiceCollection builder) { builder.AddSingleton <ISpecificationsRepository, SpecificationsRepository>(); builder .AddSingleton <ISpecificationsService, SpecificationsService>() .AddSingleton <IHealthChecker, SpecificationsService>(); builder.AddSingleton <IValidator <PolicyCreateModel>, PolicyCreateModelValidator>(); builder.AddSingleton <IValidator <PolicyEditModel>, PolicyEditModelValidator>(); builder.AddSingleton <IValidator <CalculationCreateModel>, CalculationCreateModelValidator>(); builder.AddSingleton <IValidator <SpecificationCreateModel>, SpecificationCreateModelValidator>(); builder.AddSingleton <IValidator <CalculationEditModel>, CalculationEditModelValidator>(); builder.AddSingleton <IValidator <SpecificationEditModel>, SpecificationEditModelValidator>(); builder.AddSingleton <IValidator <AssignDefinitionRelationshipMessage>, AssignDefinitionRelationshipMessageValidator>(); builder .AddSingleton <ISpecificationsSearchService, SpecificationsSearchService>() .AddSingleton <IHealthChecker, SpecificationsSearchService>(); builder.AddSingleton <IResultsRepository, ResultsRepository>(); builder.AddSingleton <ICalculationsRepository, CalculationsRepository>(); builder.AddSingleton <IFundingService, FundingService>(); builder.AddSingleton <ICosmosRepository, CosmosRepository>(); builder.AddSingleton <IVersionRepository <SpecificationVersion>, VersionRepository <SpecificationVersion> >((ctx) => { CosmosDbSettings specsVersioningDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", specsVersioningDbSettings); specsVersioningDbSettings.CollectionName = "specs"; CosmosRepository resultsRepostory = new CosmosRepository(specsVersioningDbSettings); return(new VersionRepository <SpecificationVersion>(resultsRepostory)); }); MapperConfiguration mappingConfig = new MapperConfiguration(c => c.AddProfile <SpecificationsMappingProfile>()); builder.AddFeatureToggling(Configuration); builder.AddSingleton(mappingConfig.CreateMapper()); builder.AddUserProviderFromRequest(); builder.AddCosmosDb(Configuration); builder.AddServiceBus(Configuration); builder.AddSearch(Configuration); builder.AddCaching(Configuration); builder.AddResultsInterServiceClient(Configuration); builder.AddJobsInterServiceClient(Configuration); builder.AddCalcsInterServiceClient(Configuration); builder.AddPolicySettings(Configuration); builder.AddSingleton <ISpecificationsResiliencePolicies>((ctx) => { PolicySettings policySettings = ctx.GetService <PolicySettings>(); BulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); Polly.Policy redisPolicy = ResiliencePolicyHelpers.GenerateRedisPolicy(totalNetworkRequestsPolicy); return(new SpecificationsResiliencePolicies() { JobsApiClient = ResiliencePolicyHelpers.GenerateRestRepositoryPolicy(totalNetworkRequestsPolicy) }); }); builder.AddApplicationInsights(Configuration, "CalculateFunding.Api.Specs"); builder.AddApplicationInsightsTelemetryClient(Configuration, "CalculateFunding.Apis.Specs"); builder.AddLogging("CalculateFunding.Apis.Specs"); builder.AddTelemetry(); builder.AddApiKeyMiddlewareSettings((IConfigurationRoot)Configuration); builder.AddHttpContextAccessor(); builder.AddHealthCheckMiddleware(); }
public void RegisterComponents(IServiceCollection builder) { builder.AddSingleton <IUserProfileProvider, UserProfileProvider>(); builder.AddSingleton <IValidator <SetFundingStreamCurrentProviderVersionRequest>, SetFundingStreamCurrentProviderVersionRequestValidator>(); builder.AddSingleton <IFundingStreamProviderVersionService, FundingStreamProviderVersionService>(); builder .AddSingleton <IHealthChecker, ControllerResolverHealthCheck>(); builder.AddCaching(Configuration); builder .AddSingleton <IProviderVersionService, ProviderVersionService>() .AddSingleton <IHealthChecker, ProviderVersionService>(); builder .AddSingleton <IProviderVersionSearchService, ProviderVersionSearchService>() .AddSingleton <IHealthChecker, ProviderVersionSearchService>(); builder .AddSingleton <IJobManagement, JobManagement>(); builder .AddSingleton <IScopedProvidersService, ScopedProvidersService>() .AddSingleton <IHealthChecker, ScopedProvidersService>(); builder .AddSingleton <IProviderVersionUpdateCheckService, ProviderVersionUpdateCheckService>(); builder.AddSingleton <IValidator <ProviderVersionViewModel>, UploadProviderVersionValidator>(); builder.AddSearch(this.Configuration); builder .AddSingleton <ISearchRepository <ProvidersIndex>, SearchRepository <ProvidersIndex> >(); builder .AddSingleton <IBlobClient, BlobClient>((ctx) => { AzureStorageSettings storageSettings = new AzureStorageSettings(); Configuration.Bind("AzureStorageSettings", storageSettings); storageSettings.ContainerName = "providerversions"; return(new BlobClient(storageSettings)); }); builder.AddSingleton <IProviderVersionsMetadataRepository, ProviderVersionsMetadataRepository>( ctx => { CosmosDbSettings specRepoDbSettings = new CosmosDbSettings(); Configuration.Bind("CosmosDbSettings", specRepoDbSettings); specRepoDbSettings.ContainerName = "providerversionsmetadata"; CosmosRepository cosmosRepository = new CosmosRepository(specRepoDbSettings); return(new ProviderVersionsMetadataRepository(cosmosRepository)); }); builder.AddPolicySettings(Configuration); MapperConfiguration providerVersionsConfig = new MapperConfiguration(c => { c.AddProfile <ProviderVersionsMappingProfile>(); }); builder .AddSingleton(providerVersionsConfig.CreateMapper()); builder.AddPoliciesInterServiceClient(Configuration); builder.AddResultsInterServiceClient(Configuration); builder.AddSpecificationsInterServiceClient(Configuration); builder.AddJobsInterServiceClient(Configuration); builder.AddApplicationInsightsTelemetry(); builder.AddApplicationInsightsTelemetryClient(Configuration, "CalculateFunding.Api.Providers"); builder.AddApplicationInsightsServiceName(Configuration, "CalculateFunding.Api.Providers"); builder.AddLogging("CalculateFunding.Api.Providers"); builder.AddTelemetry(); builder.AddServiceBus(Configuration); PolicySettings policySettings = ServiceCollectionExtensions.GetPolicySettings(Configuration); AsyncBulkheadPolicy totalNetworkRequestsPolicy = ResiliencePolicyHelpers.GenerateTotalNetworkRequestsPolicy(policySettings); ProvidersResiliencePolicies resiliencePolicies = CreateResiliencePolicies(totalNetworkRequestsPolicy); builder.AddSingleton <IJobManagementResiliencePolicies>(resiliencePolicies); builder.AddSingleton <IProvidersResiliencePolicies>(resiliencePolicies); builder .AddSingleton <IFileSystemCache, FileSystemCache>() .AddSingleton <IFileSystemAccess, FileSystemAccess>() .AddSingleton <IFileSystemCacheSettings, FileSystemCacheSettings>(); builder .AddSingleton <IProviderVersionServiceSettings>(ctx => { ProviderVersionServiceSettings settings = new ProviderVersionServiceSettings(); Configuration.Bind("providerversionservicesettings", settings); return(settings); }); builder .AddSingleton <IScopedProvidersServiceSettings>(ctx => { ScopedProvidersServiceSettings settings = new ScopedProvidersServiceSettings(); Configuration.Bind("scopedprovidersservicesetting", settings); return(settings); }); builder.AddApiKeyMiddlewareSettings((IConfigurationRoot)Configuration); builder.AddHealthCheckMiddleware(); builder.AddHttpContextAccessor(); builder.AddSearch(Configuration); if (Configuration.IsSwaggerEnabled()) { builder.ConfigureSwaggerServices(title: "Provider Microservice API"); } }