示例#1
0
        protected override Task OnDequeued(object sender, DequeuedEventArgs <T> dequeuedEventArgs)
        {
            _timer.ScheduleNext(SystemClock.UtcNow.Add(_reportInterval));

            var    metadata      = dequeuedEventArgs.Entry as IQueueEntryMetadata;
            string subMetricName = GetSubMetricName(dequeuedEventArgs.Entry.Value);

            if (!String.IsNullOrEmpty(subMetricName))
            {
                _metricsClient.Counter(GetFullMetricName(subMetricName, "dequeued"));
            }
            _metricsClient.Counter(GetFullMetricName("dequeued"));

            if (metadata == null || metadata.EnqueuedTimeUtc == DateTime.MinValue || metadata.DequeuedTimeUtc == DateTime.MinValue)
            {
                return(Task.CompletedTask);
            }

            var start = metadata.EnqueuedTimeUtc;
            var end   = metadata.DequeuedTimeUtc;
            int time  = (int)(end - start).TotalMilliseconds;

            if (!String.IsNullOrEmpty(subMetricName))
            {
                _metricsClient.Timer(GetFullMetricName(subMetricName, "queuetime"), time);
            }
            _metricsClient.Timer(GetFullMetricName("queuetime"), time);

            return(Task.CompletedTask);
        }
示例#2
0
        protected override async Task OnDequeued(object sender, DequeuedEventArgs <T> dequeuedEventArgs)
        {
            await base.OnDequeued(sender, dequeuedEventArgs).AnyContext();

            _timer.ScheduleNext();

            var    metadata         = dequeuedEventArgs.Entry as IQueueEntryMetadata;
            string customMetricName = GetCustomMetricName(dequeuedEventArgs.Entry.Value);

            if (!String.IsNullOrEmpty(customMetricName))
            {
                await _metricsClient.CounterAsync(GetFullMetricName(customMetricName, "dequeued")).AnyContext();
            }
            await _metricsClient.CounterAsync(GetFullMetricName("dequeued")).AnyContext();

            if (metadata == null || metadata.EnqueuedTimeUtc == DateTime.MinValue || metadata.DequeuedTimeUtc == DateTime.MinValue)
            {
                return;
            }

            var start = metadata.EnqueuedTimeUtc;
            var end   = metadata.DequeuedTimeUtc;
            var time  = (int)(end - start).TotalMilliseconds;

            if (!String.IsNullOrEmpty(customMetricName))
            {
                await _metricsClient.TimerAsync(GetFullMetricName(customMetricName, "queuetime"), time).AnyContext();
            }
            await _metricsClient.TimerAsync(GetFullMetricName("queuetime"), time).AnyContext();
        }
示例#3
0
        protected virtual Task OnDequeuedAsync(IQueueEntry <T> entry)
        {
            var args = new DequeuedEventArgs <T> {
                Queue = this, Entry = entry
            };

            return(Dequeued?.InvokeAsync(this, args) ?? Task.CompletedTask);
        }
示例#4
0
        protected override async Task OnDequeued(object sender, DequeuedEventArgs <T> dequeuedEventArgs)
        {
            string uniqueIdentifier = GetUniqueIdentifier(dequeuedEventArgs.Entry.Value);

            if (String.IsNullOrEmpty(uniqueIdentifier))
            {
                return;
            }

            await _cacheClient.RemoveAsync(uniqueIdentifier);
        }
示例#5
0
文件: QueueBase.cs 项目: nj/Foundatio
        protected virtual Task OnDequeuedAsync(IQueueEntry <T> entry)
        {
            var dequeued = Dequeued;

            if (dequeued == null)
            {
                return(Task.CompletedTask);
            }

            var args = new DequeuedEventArgs <T> {
                Queue = this, Entry = entry
            };

            return(dequeued.InvokeAsync(this, args));
        }
示例#6
0
        protected virtual Task OnDequeuedAsync(IQueueEntry <T> entry)
        {
            LastDequeueActivity = SystemClock.UtcNow;

            var dequeued = Dequeued;

            if (dequeued == null)
            {
                return(Task.CompletedTask);
            }

            var args = new DequeuedEventArgs <T> {
                Queue = this, Entry = entry
            };

            return(dequeued.InvokeAsync(this, args));
        }
示例#7
0
        protected override async Task OnDequeued(object sender, DequeuedEventArgs <T> dequeuedEventArgs)
        {
            await base.OnDequeued(sender, dequeuedEventArgs).AnyContext();

            await ReportQueueCountAsync().AnyContext();

            string customMetricName = GetCustomMetricName(dequeuedEventArgs.Data);

            if (!String.IsNullOrEmpty(customMetricName))
            {
                dequeuedEventArgs.Metadata.Data[CustomMetricNameKey] = customMetricName;
            }

            if (!String.IsNullOrEmpty(customMetricName))
            {
                await _metricsClient.CounterAsync(GetFullMetricName(customMetricName, "dequeued")).AnyContext();
            }
            await _metricsClient.CounterAsync(GetFullMetricName("dequeued")).AnyContext();

            var metadata = dequeuedEventArgs.Metadata;

            if (metadata == null || metadata.EnqueuedTimeUtc == DateTime.MinValue || metadata.DequeuedTimeUtc == DateTime.MinValue)
            {
                return;
            }

            var start = metadata.EnqueuedTimeUtc;
            var end   = metadata.DequeuedTimeUtc;
            var time  = (long)(end - start).TotalMilliseconds;

            if (!String.IsNullOrEmpty(customMetricName))
            {
                await _metricsClient.TimerAsync(GetFullMetricName(customMetricName, "queuetime"), time).AnyContext();
            }
            await _metricsClient.TimerAsync(GetFullMetricName("queuetime"), time).AnyContext();
        }
示例#8
0
 protected virtual Task OnDequeued(object sender, DequeuedEventArgs <T> dequeuedEventArgs)
 {
     return(TaskHelper.Completed());
 }