Пример #1
0
 /// <summary>
 /// Initializes a new  instance of the <see cref="AircloakConnection" /> class.
 /// </summary>
 /// <param name="apiClient">The helper API client object which will be used to make HTTP requests to the Aircloak system.</param>
 /// <param name="apiUrl">The base url of the Aircloak Api.</param>
 /// <param name="dataSourceName">The data source to run the queries against.</param>
 /// <param name="pollFrequency">The interval to be used for polling query results.</param>
 /// <param name="cancellationToken">A <see cref="CancellationToken" /> that signals the query to abort.</param>
 public AircloakConnection(
     JsonApiClient apiClient,
     Uri apiUrl,
     string dataSourceName,
     TimeSpan pollFrequency,
     CancellationToken cancellationToken)
 {
     this.apiUrl            = apiUrl;
     this.apiClient         = apiClient;
     this.dataSourceName    = dataSourceName;
     this.pollFrequency     = pollFrequency;
     this.cancellationToken = cancellationToken;
 }
Пример #2
0
        /// <summary>
        /// Initializes a new  instance of the <see cref="AircloakConnection" /> class.
        /// </summary>
        /// <param name="apiClient">The helper API client object which will be used to make HTTP requests to the Aircloak system.</param>
        /// <param name="apiUrl">The base url of the Aircloak Api.</param>
        /// <param name="dataSourceName">The data source to run the queries against.</param>
        /// <param name="options">The connection options.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken" /> that signals the query to abort.</param>
        public AircloakConnection(
            JsonApiClient apiClient,
            Uri apiUrl,
            string dataSourceName,
            IOptions <ConnectionOptions> options,
            CancellationToken cancellationToken)
        {
            this.apiUrl            = apiUrl;
            this.apiClient         = apiClient;
            this.dataSourceName    = dataSourceName;
            this.cancellationToken = cancellationToken;

            pollFrequency = TimeSpan.FromMilliseconds(options.Value.PollingInterval);
            semaphore     = Semaphores.GetOrAdd(apiUrl, _ => new SemaphoreSlim(options.Value.MaxConcurrentQueries));
        }