public TheGetRetryPolicyMethod(ITestOutputHelper output) { LoggerFactory = new LoggerFactory().AddXunit(output); HttpClientHandler = new Mock <TestHttpClientHandler> { CallBase = true }; SearchServiceClient = new SearchServiceClient( "test-search-service", new SearchCredentials("api-key"), HttpClientHandler.Object, DependencyInjectionExtensions.GetSearchDelegatingHandlers(LoggerFactory)); SearchServiceClient.SetRetryPolicy(SingleRetry); IndexesOperationsWrapper = new IndexesOperationsWrapper( SearchServiceClient.Indexes, DependencyInjectionExtensions.GetSearchDelegatingHandlers(LoggerFactory), SingleRetry, LoggerFactory.CreateLogger <DocumentsOperationsWrapper>()); }
public static IServiceCollection AddAzureSearch( this IServiceCollection services, IDictionary <string, string> telemetryGlobalDimensions) { services.AddV3(telemetryGlobalDimensions); services.AddFeatureFlags(); services.AddTransient <IFeatureFlagService, FeatureFlagService>(); services.AddTransient <ISearchServiceClientWrapper>(p => new SearchServiceClientWrapper( p.GetRequiredService <ISearchServiceClient>(), GetSearchDelegatingHandlers(p.GetRequiredService <ILoggerFactory>()), GetSearchRetryPolicy(), p.GetRequiredService <ILogger <DocumentsOperationsWrapper> >())); services .AddTransient <ISearchServiceClient>(p => { var options = p.GetRequiredService <IOptionsSnapshot <AzureSearchConfiguration> >(); var client = new SearchServiceClient( options.Value.SearchServiceName, new SearchCredentials(options.Value.SearchServiceApiKey), new WebRequestHandler(), GetSearchDelegatingHandlers(p.GetRequiredService <ILoggerFactory>())); client.SetRetryPolicy(GetSearchRetryPolicy()); return(client); }); services.AddSingleton <IAuxiliaryDataCache, AuxiliaryDataCache>(); services.AddScoped(p => p.GetRequiredService <IAuxiliaryDataCache>().Get()); services.AddSingleton <IAuxiliaryFileReloader, AuxiliaryFileReloader>(); services.AddSingleton <ISecretRefresher, SecretRefresher>(); services.AddTransient <UpdateVerifiedPackagesCommand>(); services.AddTransient <UpdateDownloadsCommand>(); services.AddTransient <UpdateOwnersCommand>(); services.AddTransient(p => new Auxiliary2AzureSearchCommand( p.GetRequiredService <UpdateVerifiedPackagesCommand>(), p.GetRequiredService <UpdateDownloadsCommand>(), p.GetRequiredService <UpdateOwnersCommand>(), p.GetRequiredService <IAzureSearchTelemetryService>(), p.GetRequiredService <ILogger <Auxiliary2AzureSearchCommand> >())); services.AddTransient <IAzureSearchTelemetryService, AzureSearchTelemetryService>(); services.AddTransient <IBaseDocumentBuilder, BaseDocumentBuilder>(); services.AddTransient <ICatalogIndexActionBuilder, CatalogIndexActionBuilder>(); services.AddTransient <ICatalogLeafFetcher, CatalogLeafFetcher>(); services.AddTransient <ICommitCollectorLogic, AzureSearchCollectorLogic>(); services.AddTransient <IDatabaseAuxiliaryDataFetcher, DatabaseAuxiliaryDataFetcher>(); services.AddTransient <IDataSetComparer, DataSetComparer>(); services.AddTransient <IDocumentFixUpEvaluator, DocumentFixUpEvaluator>(); services.AddTransient <IDownloadSetComparer, DownloadSetComparer>(); services.AddTransient <IDownloadTransferrer, DownloadTransferrer>(); services.AddTransient <IEntitiesContextFactory, EntitiesContextFactory>(); services.AddTransient <IHijackDocumentBuilder, HijackDocumentBuilder>(); services.AddTransient <IIndexBuilder, IndexBuilder>(); services.AddTransient <IIndexOperationBuilder, IndexOperationBuilder>(); services.AddTransient <INewPackageRegistrationProducer, NewPackageRegistrationProducer>(); services.AddTransient <IPackageEntityIndexActionBuilder, PackageEntityIndexActionBuilder>(); services.AddTransient <ISearchDocumentBuilder, SearchDocumentBuilder>(); services.AddTransient <ISearchIndexActionBuilder, SearchIndexActionBuilder>(); services.AddTransient <ISearchParametersBuilder, SearchParametersBuilder>(); services.AddTransient <ISearchResponseBuilder, SearchResponseBuilder>(); services.AddTransient <ISearchTextBuilder, SearchTextBuilder>(); services.AddTransient <IServiceClientTracingInterceptor, ServiceClientTracingLogger>(); services.AddTransient <ISystemTime, SystemTime>(); return(services); }