public QoSTrackerQueryHandlerDecorator(IQueryHandler <TQuery, TResult> handler, ITracer tracer,
                                               IQoSTrackingSampler trackingSampler, IQoSTimeViolationChecker <TQuery> qoSViolateChecker,
                                               QoSTrackingOptions trackingOptions)
        {
            _handler           = handler;
            _tracer            = tracer;
            _trackingSampler   = trackingSampler;
            _qoSViolateChecker = qoSViolateChecker;

            _withTracing = trackingOptions.EnabledTracing && tracer is { };
        }
        public QoSTrackerEventHandlerDecorator(IEventHandler <TEvent> handler, ITracer tracer,
                                               IQoSTrackingSampler trackingSampler, IQoSTimeViolationChecker <TEvent> qoSViolateChecker, IQoSViolateRaiser qoSViolateRaiser,
                                               QoSTrackingOptions trackingOptions)
        {
            _handler           = handler;
            _tracer            = tracer;
            _trackingSampler   = trackingSampler;
            _qoSViolateChecker = qoSViolateChecker;
            _qoSViolateRaiser  = qoSViolateRaiser;

            _withTracing = trackingOptions.EnabledTracing && tracer is { };
        }
        public QoSTimeViolationChecker(IQoSCacheFormatter qoSCacheFormatter, IQoSViolateRaiser qoSViolateRaiser,
                                       IDistributedCache distributedCache, IMemoryCache memoryCache,
                                       ILogger <IQoSTimeViolationChecker <TMessage> > logger, QoSTrackingOptions options, AppOptions appOptions)
        {
            _qoSCacheFormatter  = qoSCacheFormatter;
            _qoSViolateRaiser   = qoSViolateRaiser;
            _distributedCache   = distributedCache;
            _memoryCache        = memoryCache;
            _logger             = logger;
            _windowComparerSize = options.WindowComparerSize;

            var appServiceName       = appOptions.Service;
            var messageName          = this.GetMessageName();
            var timeViolationOptions = options.QoSTimeViolationOptions;

            void AssignCacheMessageName()
            {
                _cacheMsgName = $"{appServiceName.ToLower()}_{messageName}";
            }

            double ChooseTimeCoefficient(char messageShort)
            => messageShort switch
            {
                'c' => timeViolationOptions.CommandExceedingCoefficient,
                'q' => timeViolationOptions.QueryExceedingCoefficient,
                'e' => timeViolationOptions.EventExceedingCoefficient,
                _ => 0.0
            };

            AssignCacheMessageName();
            _timeViolationCoefficient = ChooseTimeCoefficient(messageName.First());
        }
示例#4
0
 public QoSTrackingSampler(QoSTrackingOptions options)
 {
     _samplingRate = options.SamplingRate;
 }