Пример #1
0
        public OperatorHandler(
            IOptionsSnapshot <OperatorOptions> optionsProvider,
            IOperatorCache <TResource> cache,
            IOperatorReconciler <TResource> reconciler,
            ILogger <OperatorHandler <TResource> > logger)
        {
            if (optionsProvider is null)
            {
                throw new ArgumentNullException(nameof(optionsProvider));
            }

            var options = optionsProvider.Get(_names.PluralNameGroup);

            foreach (var informer in options.Informers)
            {
                _registrations.Add(informer.Register(Notification));
            }

            var rateLimiter = options.NewRateLimiter();

            _queue      = options.NewRateLimitingQueue(rateLimiter);
            _cache      = cache;
            _reconciler = reconciler;
            _logger     = logger;
        }
Пример #2
0
        public IngressController(
            ICache cache,
            IReconciler reconciler,
            IResourceInformer <V1Ingress> ingressInformer,
            IResourceInformer <V1Service> serviceInformer,
            IResourceInformer <V1Endpoints> endpointsInformer,
            IHostApplicationLifetime hostApplicationLifetime,
            ILogger <IngressController> logger)
            : base(hostApplicationLifetime, logger)
        {
            if (ingressInformer is null)
            {
                throw new ArgumentNullException(nameof(ingressInformer));
            }

            if (serviceInformer is null)
            {
                throw new ArgumentNullException(nameof(serviceInformer));
            }

            if (endpointsInformer is null)
            {
                throw new ArgumentNullException(nameof(endpointsInformer));
            }

            if (hostApplicationLifetime is null)
            {
                throw new ArgumentNullException(nameof(hostApplicationLifetime));
            }

            if (logger is null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            _registrations = new[]
            {
                ingressInformer.Register(Notification),
                serviceInformer.Register(Notification),
                endpointsInformer.Register(Notification),
            };

            _queue = new RateLimitingQueue <QueueItem>(new MaxOfRateLimiter <QueueItem>(
                                                           new BucketRateLimiter <QueueItem>(
                                                               limiter: new Limiter(
                                                                   limit: new Limit(perSecond: 10),
                                                                   burst: 100)),
                                                           new ItemExponentialFailureRateLimiter <QueueItem>(
                                                               baseDelay: TimeSpan.FromMilliseconds(5),
                                                               maxDelay: TimeSpan.FromSeconds(10))));

            _cache      = cache ?? throw new ArgumentNullException(nameof(cache));
            _reconciler = reconciler ?? throw new ArgumentNullException(nameof(reconciler));
            _reconciler.OnAttach(TargetAttached);
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RateLimitingQueueBase{TItem}" /> class.
 /// </summary>
 /// <param name="base">The base.</param>
 protected RateLimitingQueueBase(IRateLimitingQueue <TItem> @base)
     : base(@base)
 {
     _base = @base;
 }