public RequestRouter(CryptowatchApiOptions configuration, IRequestMeteringMonitor requestMeteringMonitor) { Monitor = requestMeteringMonitor; _httpClient = new HttpClient() { BaseAddress = new Uri("https://api.cryptowat.ch/") }; _httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); _httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(configuration.UserAgent, configuration.UserAgentVersion)); }
public RequestMeteringMonitor(CryptowatchApiOptions configuration) { _meterMaxValue = configuration.RequestMeterMaximum; var stopThresholdPercentage = configuration.StopThresholdPercentage; _stopThreshold = (long)Math.Round(_meterMaxValue * stopThresholdPercentage); _serializerLock = new object(); _resultsProcessingLock = new object(); _requestSerial = 0; _processedSerial = 0; _currentMeterValue = _meterMaxValue; Task.Run(MeterResetWorker); }