public ConcurrencyLimitFilterManagementConsumer(IPipeRouter router, string id = null)
        {
            _router = router;
            _id     = id;

            _lastUpdated = DateTime.UtcNow;
        }
Beispiel #2
0
        /// <summary>
        /// Specify a rate limit for message processing, so that only the specified number of messages are allowed
        /// per interval.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="configurator"></param>
        /// <param name="rateLimit">The number of messages allowed per interval</param>
        /// <param name="interval">The reset interval for each set of messages</param>
        /// <param name="router">The control pipe used to adjust the rate limit dynamically</param>
        public static void UseRateLimit <T>(this IPipeConfigurator <T> configurator, int rateLimit, TimeSpan interval, IPipeRouter router = null)
            where T : class, PipeContext
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            var specification = new RateLimitPipeSpecification <T>(rateLimit, interval, router);

            configurator.AddPipeSpecification(specification);
        }
 public MyController(IPipeRouter router)
 {
     _router = router;
 }
 public RateLimitPipeSpecification(int rateLimit, TimeSpan interval, IPipeRouter router = null)
 {
     _rateLimit = rateLimit;
     _interval  = interval;
     _router    = router;
 }
        public ConcurrencyLimitPipeSpecification(int concurrencyLimit, IPipeRouter router = null)
        {
            _concurrencyLimit = concurrencyLimit;

            _router = router;
        }
Beispiel #6
0
        /// <summary>
        /// Specify a concurrency limit for tasks executing through the filter. No more than the specified
        /// number of tasks will be allowed to execute concurrently.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="configurator"></param>
        /// <param name="concurrencyLimit">The concurrency limit for the subsequent filters in the pipeline</param>
        /// <param name="router">A control pipe to support runtime adjustment</param>
        public static void UseConcurrencyLimit <T>(this IPipeConfigurator <T> configurator, int concurrencyLimit, IPipeRouter router = null)
            where T : class, PipeContext
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            var specification = new ConcurrencyLimitPipeSpecification <T>(concurrencyLimit, router);

            configurator.AddPipeSpecification(specification);
        }
Beispiel #7
0
        public ConcurrencyLimitPipeSpecification(int concurrencyLimit)
        {
            _concurrencyLimit = concurrencyLimit;

            _dynamicRouter = new PipeRouter();
        }