/// <summary>
 /// Initializes a new instance of the <see cref="UserResponseDataRefreshService"/> class.
 /// BackgroundService class that inherits IHostedService and implements the methods related to re-create Azure Search service related resources like: Indexes and Indexer tasks.
 /// </summary>
 /// <param name="logger">Instance to send logs to the Application Insights service.</param>
 /// <param name="userResponseSearchService">The user response search service dependency injection.</param>
 /// <param name="optionsAccessor">A set of key/value application configuration properties.</param>
 public UserResponseDataRefreshService(
     ILogger <UserResponseDataRefreshService> logger,
     IUserResponseSearchService userResponseSearchService,
     IOptions <SearchServiceSetting> optionsAccessor)
 {
     this.logger = logger;
     this.userResponseSearchService = userResponseSearchService;
     this.options = optionsAccessor?.Value;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostSearchService"/> class.
        /// </summary>
        /// <param name="optionsAccessor">A set of key/value application configuration properties.</param>
        /// <param name="postStorageProvider">Post storage provider dependency injection.</param>
        /// <param name="logger">Instance to send logs to the Application Insights service.</param>
        /// <param name="searchServiceClient">Search service client dependency injection.</param>
        /// <param name="searchIndexClient">Search index client dependency injection.</param>
        public PostSearchService(
            IOptions <SearchServiceSetting> optionsAccessor,
            IPostStorageProvider postStorageProvider,
            ILogger <PostSearchService> logger,
            ISearchServiceClient searchServiceClient,
            ISearchIndexClient searchIndexClient)
        {
            optionsAccessor = optionsAccessor ?? throw new ArgumentNullException(nameof(optionsAccessor));

            this.options = optionsAccessor.Value;
            var searchServiceValue = this.options.SearchServiceName;

            this.initializeTask      = new Lazy <Task>(() => this.InitializeAsync());
            this.postStorageProvider = postStorageProvider;
            this.logger = logger;
            this.searchServiceClient = searchServiceClient;
            this.searchIndexClient   = searchIndexClient;
            this.retryPolicy         = Policy.Handle <CloudException>().WaitAndRetryAsync(Backoff.LinearBackoff(TimeSpan.FromMilliseconds(2000), 2));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UserResponseSearchService"/> class.
        /// </summary>
        /// <param name="optionsAccessor">A set of key/value application configuration properties.</param>
        /// <param name="userResponseStorageProvider">User response storage provider dependency injection.</param>
        /// <param name="logger">Instance to send logs to the Application Insights service.</param>
        public UserResponseSearchService(
            IOptions <SearchServiceSetting> optionsAccessor,
            IUserResponseStorageProvider userResponseStorageProvider,
            ILogger <UserResponseSearchService> logger)
        {
            optionsAccessor = optionsAccessor ?? throw new ArgumentNullException(nameof(optionsAccessor));

            this.options = optionsAccessor.Value;
            var searchServiceValue = this.options.SearchServiceName;

            this.searchServiceClient = new SearchServiceClient(
                searchServiceValue,
                new SearchCredentials(this.options.SearchServiceAdminApiKey));
            this.searchIndexClient = new SearchIndexClient(
                searchServiceValue,
                UserResponseIndexName,
                new SearchCredentials(this.options.SearchServiceQueryApiKey));
            this.searchIndexingIntervalInMinutes = Convert.ToInt32(this.options.SearchIndexingIntervalInMinutes, CultureInfo.InvariantCulture);

            this.initializeTask = new Lazy <Task>(() => this.InitializeAsync(this.options.ConnectionString));
            this.userResponseStorageProvider = userResponseStorageProvider;
            this.logger = logger;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectSearchService"/> class.
        /// </summary>
        /// <param name="optionsAccessor">A set of key/value application configuration properties.</param>
        /// <param name="projectStorageProvider">Project storage provider dependency injection.</param>
        /// <param name="logger">Logger implementation to send logs to the logger service.</param>
        /// <param name="searchServiceClient">Search service client dependency injection.</param>
        /// <param name="searchIndexClient">Search index client dependency injection.</param>
        /// <param name="projectHelper">Helper for creating models and filtering projects as per criteria.</param>
        public ProjectSearchService(
            IOptions <SearchServiceSetting> optionsAccessor,
            IProjectStorageProvider projectStorageProvider,
            ILogger <ProjectSearchService> logger,
            ISearchServiceClient searchServiceClient,
            ISearchIndexClient searchIndexClient,
            IProjectHelper projectHelper)
        {
            optionsAccessor = optionsAccessor ?? throw new ArgumentNullException(nameof(optionsAccessor));

            this.options = optionsAccessor.Value;
            var searchServiceValue = this.options.SearchServiceName;

            this.initializeTask         = new Lazy <Task>(() => this.InitializeAsync());
            this.projectStorageProvider = projectStorageProvider;
            this.logger = logger;
            this.searchServiceClient = searchServiceClient;
            this.searchIndexClient   = searchIndexClient;
            this.retryPolicy         = Policy.Handle <CloudException>(
                ex => (int)ex.Response.StatusCode == StatusCodes.Status409Conflict ||
                (int)ex.Response.StatusCode == StatusCodes.Status429TooManyRequests)
                                       .WaitAndRetryAsync(Backoff.LinearBackoff(TimeSpan.FromMilliseconds(2000), 2));
            this.projectHelper = projectHelper;
        }