/// <summary>
 /// Initializes new instances of <see cref="RequestRateLimiterMiddleware"/> class.
 /// </summary>
 /// <param name="next">
 /// The next item in the middleware pipeline.
 /// </param>
 /// <param name="configuration">
 /// The congestion control configuration.
 /// </param>
 /// <param name="tokenBucketConsumer">
 /// The token bucket consumer.
 /// </param>
 /// <param name="httpResponseFormatter">
 /// The rate limit response formatter.
 /// </param>
 /// <param name="logger">
 /// The logger.
 /// </param>
 public RequestRateLimiterMiddleware(
     RequestDelegate next,
     CongestionControlConfiguration configuration,
     ITokenBucketConsumer tokenBucketConsumer,
     IHttpResponseFormatter httpResponseFormatter,
     ILogger <RequestRateLimiterMiddleware> logger)
 {
     _next                  = next;
     _configuration         = configuration;
     _tokenBucketConsumer   = tokenBucketConsumer;
     _httpResponseFormatter = httpResponseFormatter;
     _logger                = logger;
 }
 /// <summary>
 /// Initializes a new instance of <see cref="ConcurrentRequestLimiterMiddleware"/>
 /// class.
 /// </summary>
 /// <param name="next">
 /// The next item in the middleware pipeline.
 /// </param>
 /// <param name="configuration">
 /// The congestion control configuration.
 /// </param>
 /// <param name="concurrentRequestsManager">
 /// The concurrent request manager.
 /// </param>
 /// <param name="httpResponseFormatter">
 /// The HTTP response formatter.
 /// </param>
 /// <param name="logger">
 /// The logger.
 /// </param>
 public ConcurrentRequestLimiterMiddleware(
     RequestDelegate next,
     CongestionControlConfiguration configuration,
     IConcurrentRequestsManager concurrentRequestsManager,
     IHttpResponseFormatter httpResponseFormatter,
     ILogger <ConcurrentRequestLimiterMiddleware> logger)
 {
     _next                      = next;
     _configuration             = configuration;
     _concurrentRequestsManager = concurrentRequestsManager;
     _httpResponseFormatter     = httpResponseFormatter;
     _logger                    = logger;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds custom HTTP response formatter.
 /// </summary>
 /// <param name="httpResponseFormatter">
 /// The implementation of <see cref="IHttpResponseFormatter"/> interface.
 /// </param>
 /// <exception cref="ArgumentNullException"></exception>
 public void AddHttpResponseFormatter(IHttpResponseFormatter httpResponseFormatter)
 {
     HttpResponseFormatter = httpResponseFormatter ?? throw new ArgumentNullException(nameof(httpResponseFormatter));
 }