Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PostController"/> class.
 /// </summary>
 /// <param name="logger">Sends logs to the Application Insights service.</param>
 /// <param name="telemetryClient">The Application Insights telemetry client.</param>
 /// <param name="postStorageHelper">Helper for creating models and filtering posts as per criteria.</param>
 /// <param name="postStorageProvider">Provides methods for add, update and delete post operations from database.</param>
 /// <param name="postSearchService">Post search service for fetching post with search criteria and filters.</param>
 public PostController(
     ILogger <TeamPostController> logger,
     TelemetryClient telemetryClient,
     IPostStorageHelper postStorageHelper,
     IPostStorageProvider postStorageProvider,
     IPostSearchService postSearchService)
     : base(telemetryClient)
 {
     this.logger              = logger;
     this.postStorageHelper   = postStorageHelper;
     this.postStorageProvider = postStorageProvider;
     this.postSearchService   = postSearchService;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="UserVoteController"/> class.
 /// </summary>
 /// <param name="logger">Used to perform logging of errors and information.</param>
 /// <param name="telemetryClient">The Application Insights telemetry client.</param>
 /// <param name="userVoteStorageProvider">Provider for working with user vote data in storage.</param>
 /// <param name="postStorageProvider">Provider to fetch posts from storage.</param>
 /// <param name="postSearchService">Search service instance for fetching posts using filters and search queries.</param>
 public UserVoteController(
     ILogger <TeamPostController> logger,
     TelemetryClient telemetryClient,
     IUserVoteStorageProvider userVoteStorageProvider,
     IPostStorageProvider postStorageProvider,
     IPostSearchService postSearchService)
     : base(telemetryClient)
 {
     this.logger = logger;
     this.userVoteStorageProvider = userVoteStorageProvider;
     this.postStorageProvider     = postStorageProvider;
     this.postSearchService       = postSearchService;
     this.retryPolicy             = Policy.Handle <StorageException>(ex => ex.RequestInformation.HttpStatusCode == StatusCodes.Status412PreconditionFailed)
                                    .WaitAndRetryAsync(Backoff.LinearBackoff(TimeSpan.FromMilliseconds(250), 25));
 }
Пример #3
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));
        }