public MaxConcurrentRequestsMiddleware(RequestDelegate next, IOptions <MaxConcurrentRequestsOptions> config) { _next = next ?? throw new ArgumentNullException(nameof(next)); if (config == null) { throw new ArgumentNullException(nameof(config)); } ; _config = config; _options = _config?.Value ?? throw new ArgumentNullException(nameof(_config.Value)); SettingEndpointStatus(_options.EndpointRules); }
/// <summary> /// Initializes a new instance of the <see cref="MaxConcurrentRequestsMiddleware"/> class. /// </summary> /// <param name="next">The next.</param> /// <param name="options">The options.</param> public MaxConcurrentRequestsMiddleware(RequestDelegate next, IOptions <MaxConcurrentRequestsOptions> options) { Argument.IsNotNull(options.Value, nameof(MaxConcurrentRequestsOptions)); Argument.IsNotNull(next); _concurrentRequestsCount = 0; _next = next; _options = options.Value; if (_options.LimitExceededPolicy != MaxConcurrentRequestsLimitExceededPolicy.Drop) { _enqueuer = new MaxConcurrentRequestsEnqueuer(_options.MaxQueueLength, (MaxConcurrentRequestsEnqueuer.DropMode)_options.LimitExceededPolicy, _options.MaxTimeInQueue); } }