public static RequestThrottlingMiddleware CreateTestMiddleware(int?maxConcurrentRequests, int requestQueueLimit = 5000, RequestDelegate onRejected = null, RequestDelegate next = null) { var options = new RequestThrottlingOptions { MaxConcurrentRequests = maxConcurrentRequests, RequestQueueLimit = requestQueueLimit }; return(BuildFromOptions(options, onRejected, next)); }
public static RequestThrottlingMiddleware CreateBlockingTestMiddleware(int requestQueueLimit = 5000, RequestDelegate onRejected = null, RequestDelegate next = null) { var options = new RequestThrottlingOptions { MaxConcurrentRequests = 999, RequestQueueLimit = requestQueueLimit, ServerAlwaysBlocks = true }; return(BuildFromOptions(options, onRejected, next)); }
private static RequestThrottlingMiddleware BuildFromOptions(RequestThrottlingOptions options, RequestDelegate onRejected, RequestDelegate next) { if (onRejected != null) { options.OnRejected = onRejected; } return(new RequestThrottlingMiddleware( next: next ?? (context => Task.CompletedTask), loggerFactory: NullLoggerFactory.Instance, options: Options.Create(options) )); }
public static RequestThrottlingMiddleware CreateTestMiddleWare(int?maxConcurrentRequests, RequestDelegate next = null) { var options = new RequestThrottlingOptions { MaxConcurrentRequests = maxConcurrentRequests }; return(new RequestThrottlingMiddleware( next: next ?? (context => Task.CompletedTask), loggerFactory: NullLoggerFactory.Instance, options: Options.Create(options) )); }
public void GlobalSetup() { var options = new RequestThrottlingOptions { MaxConcurrentRequests = MaxConcurrentRequests, RequestQueueLimit = _numRequests }; _middleware = new RequestThrottlingMiddleware( next: (RequestDelegate)_incrementAndCheck, loggerFactory: NullLoggerFactory.Instance, options: Options.Create(options) ); }
public void GlobalSetup() { _restOfServer = YieldsThreadInternally ? (RequestDelegate)YieldsThread : (RequestDelegate)CompletesImmediately; var options = new RequestThrottlingOptions { MaxConcurrentRequests = 8, RequestQueueLimit = _numRequests }; _middleware = new RequestThrottlingMiddleware( next: _restOfServer, loggerFactory: NullLoggerFactory.Instance, options: Options.Create(options) ); }
public static RequestThrottlingMiddleware CreateTestMiddleware(int?maxConcurrentRequests, int requestQueueLimit = 5000, RequestDelegate onRejected = null, RequestDelegate next = null) { var options = new RequestThrottlingOptions { MaxConcurrentRequests = maxConcurrentRequests, RequestQueueLimit = requestQueueLimit }; if (onRejected != null) { options.OnRejected = onRejected; } return(new RequestThrottlingMiddleware( next: next ?? (context => Task.CompletedTask), loggerFactory: NullLoggerFactory.Instance, options: Options.Create(options) )); }