Exemple #1
0
 public MetricTimer(string name, IMetricsClient client)
 {
     _name = name;
     _stopWatch = new Stopwatch();
     _client = client;
     _stopWatch.Start();
 }
 public ThrottleBotsPlugin(ICacheClient cacheClient, IEventRepository eventRepository, IProjectRepository projectRepository, IMetricsClient metricsClient, IQueue<WorkItemData> workItemQueue) {
     _cacheClient = cacheClient;
     _metricsClient = metricsClient;
     _eventRepository = eventRepository;
     _projectRepository = projectRepository;
     _workItemQueue = workItemQueue;
 }
 public ThrottlingHandler(ICacheClient cacheClient, IMetricsClient metricsClient, Func<string, long> maxRequestsForUserIdentifier, TimeSpan period, string message = "The allowed number of requests has been exceeded.") {
     _cacheClient = cacheClient;
     _metricsClient = metricsClient;
     _maxRequestsForUserIdentifier = maxRequestsForUserIdentifier;
     _period = period;
     _message = message;
 }
Exemple #4
0
 public Mailer(IEmailGenerator emailGenerator, IQueue<MailMessage> queue, FormattingPluginManager pluginManager, IMetricsClient metrics, ILogger<Mailer> logger) {
     _emailGenerator = emailGenerator;
     _queue = queue;
     _pluginManager = pluginManager;
     _metrics = metrics;
     _logger = logger;
 }
 public SetLocationFromGeoWorkItemHandler(ICacheClient cacheClient, IEventRepository eventRepository, IGeocodeService geocodeService, IMetricsClient metricsClient, IMessageBus messageBus, ILoggerFactory loggerFactory = null) : base(loggerFactory) {
     _cacheClient = new ScopedCacheClient(cacheClient, "geo");
     _eventRepository = eventRepository;
     _geocodeService = geocodeService;
     _metricsClient = metricsClient;
     _lockProvider = new CacheLockProvider(cacheClient, messageBus);
 }
 public EventPostsJob(IQueue<EventPost> queue, EventParserPluginManager eventParserPluginManager, EventPipeline eventPipeline, IMetricsClient metricsClient, IOrganizationRepository organizationRepository, IProjectRepository projectRepository, IFileStorage storage) {
     _queue = queue;
     _eventParserPluginManager = eventParserPluginManager;
     _eventPipeline = eventPipeline;
     _metricsClient = metricsClient;
     _organizationRepository = organizationRepository;
     _projectRepository = projectRepository;
     _storage = storage;
 }
 public StatusController(ICacheClient cacheClient, IMessagePublisher messagePublisher, SystemHealthChecker healthChecker, IQueue<EventPost> eventQueue, IQueue<MailMessage> mailQueue, IQueue<EventNotificationWorkItem> notificationQueue, IQueue<WebHookNotification> webHooksQueue, IQueue<EventUserDescription> userDescriptionQueue, IMetricsClient metricsClient) {
     _cacheClient = cacheClient;
     _messagePublisher = messagePublisher;
     _healthChecker = healthChecker;
     _eventQueue = eventQueue;
     _mailQueue = mailQueue;
     _notificationQueue = notificationQueue;
     _webHooksQueue = webHooksQueue;
     _userDescriptionQueue = userDescriptionQueue;
     _metricsClient = metricsClient;
 }
Exemple #8
0
 public static IDisposable StartTimer(this IMetricsClient client, string name)
 {
     return(new MetricTimer(name, client));
 }
Exemple #9
0
 public Mailer(IQueue <MailMessage> queue, FormattingPluginManager pluginManager, IMetricsClient metrics, ILogger <Mailer> logger)
 {
     _queue         = queue;
     _pluginManager = pluginManager;
     _metrics       = metrics;
     _logger        = logger;
 }
Exemple #10
0
 public SampleQueueJobWithLocking(IQueue <SampleQueueWorkItem> queue, IMetricsClient metrics, ILockProvider lockProvider, ILoggerFactory loggerFactory = null) : base(queue, loggerFactory)
 {
     _metrics      = metrics ?? NullMetricsClient.Instance;
     _lockProvider = lockProvider;
 }
Exemple #11
0
 public EventPipeline(IDependencyResolver dependencyResolver, IOrganizationRepository organizationRepository, IProjectRepository projectRepository, IMetricsClient statsClient) : base(dependencyResolver)
 {
     _organizationRepository = organizationRepository;
     _projectRepository      = projectRepository;
     _statsClient            = statsClient;
 }
 public IncrementCountersAction(IMetricsClient metricsClient, BillingPlans plans, IOptions <AppOptions> options, ILoggerFactory loggerFactory = null) : base(options, loggerFactory)
 {
     _metricsClient  = metricsClient;
     _plans          = plans;
     ContinueOnError = true;
 }
 public static void Counter(this IMetricsClient client, string statName, int value = 1)
 {
     client.CounterAsync(statName, value).Wait();
 }
 public static void Timer(this IMetricsClient client, string statName, long milliseconds)
 {
     client.TimerAsync(statName, milliseconds).Wait();
 }
 public MailMessageJob(IQueue<MailMessage> queue, IMailSender mailSender, IMetricsClient metricsClient) {
     _queue = queue;
     _mailSender = mailSender;
     _metricsClient = metricsClient;
 }
 public EventPostsJob(IQueue <EventPost> queue, EventParserPluginManager eventParserPluginManager, EventPipeline eventPipeline, IMetricsClient statsClient, IOrganizationRepository organizationRepository, IProjectRepository projectRepository, IFileStorage storage)
 {
     _queue = queue;
     _eventParserPluginManager = eventParserPluginManager;
     _eventPipeline            = eventPipeline;
     _statsClient            = statsClient;
     _organizationRepository = organizationRepository;
     _projectRepository      = projectRepository;
     _storage = storage;
 }
Exemple #17
0
        public RedisQueue(ConnectionMultiplexer connection, ISerializer serializer = null, string queueName = null, int retries = 2, TimeSpan?retryDelay        = null, int[] retryMultipliers = null,
                          TimeSpan?workItemTimeout = null, TimeSpan?deadLetterTimeToLive = null, int deadLetterMaxItems         = 100, bool runMaintenanceTasks = true, IMetricsClient metrics = null, string statName = null)
        {
            QueueId           = Guid.NewGuid().ToString("N");
            _db               = connection.GetDatabase();
            _serializer       = serializer ?? new JsonNetSerializer();
            _cache            = new RedisCacheClient(connection, _serializer);
            _lockProvider     = new CacheLockProvider(_cache);
            _queueName        = queueName ?? typeof(T).Name;
            _queueName        = _queueName.RemoveWhiteSpace().Replace(':', '-');
            _metrics          = metrics;
            QueueSizeStatName = statName;
            QueueListName     = "q:" + _queueName + ":in";
            WorkListName      = "q:" + _queueName + ":work";
            WaitListName      = "q:" + _queueName + ":wait";
            DeadListName      = "q:" + _queueName + ":dead";
            // TODO: Make queue settings immutable and stored in redis so that multiple clients can't have different settings.
            _retries = retries;
            if (retryDelay.HasValue)
            {
                _retryDelay = retryDelay.Value;
            }
            if (retryMultipliers != null)
            {
                _retryMultipliers = retryMultipliers;
            }
            if (workItemTimeout.HasValue)
            {
                _workItemTimeout = workItemTimeout.Value;
            }
            if (deadLetterTimeToLive.HasValue)
            {
                _deadLetterTtl = deadLetterTimeToLive.Value;
            }
            _deadLetterMaxItems = deadLetterMaxItems;

            _payloadTtl = GetPayloadTtl();

            _subscriber = connection.GetSubscriber();
            _subscriber.Subscribe(GetTopicName(), OnTopicMessage);

            if (runMaintenanceTasks)
            {
                _queueDisposedCancellationTokenSource = new CancellationTokenSource();
                TimeSpan interval = _workItemTimeout > TimeSpan.FromSeconds(1) ? _workItemTimeout.Min(TimeSpan.FromMinutes(1)) : TimeSpan.FromSeconds(1);
                _maintenanceTimer = new Timer(DoMaintenanceWork, null, interval, TimeSpan.FromMilliseconds(100));
            }

            Log.Trace().Message("Queue {0} created. Retries: {1} Retry Delay: {2}", QueueId, _retries, _retryDelay.ToString()).Write();
        }
 public EventPipeline(IServiceProvider serviceProvider, IMetricsClient metricsClient, ILoggerFactory loggerFactory = null) : base(serviceProvider, metricsClient, loggerFactory)
 {
 }
Exemple #19
0
 public Mailer(IEmailGenerator emailGenerator, IQueue <MailMessage> queue, FormattingPluginManager pluginManager, IMetricsClient statsClient)
 {
     _emailGenerator = emailGenerator;
     _queue          = queue;
     _pluginManager  = pluginManager;
     _statsClient    = statsClient;
 }
        public EventPostsJob(IQueue <EventPost> queue, EventParserPluginManager eventParserPluginManager, EventPipeline eventPipeline, IMetricsClient metricsClient, IOrganizationRepository organizationRepository, IProjectRepository projectRepository, IFileStorage storage, ILoggerFactory loggerFactory = null) : base(queue, loggerFactory)
        {
            _eventParserPluginManager = eventParserPluginManager;
            _eventPipeline            = eventPipeline;
            _metricsClient            = metricsClient;
            _organizationRepository   = organizationRepository;
            _projectRepository        = projectRepository;
            _storage = storage;

            AutoComplete = false;
        }
 public DotNetMetricJob(IDotNetMetricsRepository metricsRepository, IAgentsRepository agentsRepository, IMetricsClient metricsClient)
 {
     _metricsRepository = metricsRepository;
     _agentsRepository  = agentsRepository;
     _metricsClient     = metricsClient;
 }
Exemple #22
0
 public static void Time(this IMetricsClient client, Action action, string name)
 {
     using (client.StartTimer(name))
         action();
 }
 public OverageHandler(IOrganizationRepository organizationRepository, ICacheClient cacheClient, IMetricsClient statsClient)
 {
     _organizationRepository = organizationRepository;
     _cacheClient            = cacheClient;
     _statsClient            = statsClient;
 }
Exemple #24
0
 public MailMessageJob(IQueue <MailMessage> queue, IMailSender mailSender, IMetricsClient statsClient)
 {
     _queue       = queue;
     _mailSender  = mailSender;
     _statsClient = statsClient;
 }
 public Mailer(IQueue <MailMessage> queue, FormattingPluginManager pluginManager, IOptions <AppOptions> appOptions, IOptions <EmailOptions> emailOptions, IMetricsClient metrics, ILogger <Mailer> logger)
 {
     _queue         = queue;
     _pluginManager = pluginManager;
     _appOptions    = appOptions;
     _emailOptions  = emailOptions;
     _metrics       = metrics;
     _logger        = logger;
 }
 public static void Gauge(this IMetricsClient client, string statName, double value)
 {
     client.GaugeAsync(statName, value).Wait();
 }
 public EventParserPluginManager(IDependencyResolver dependencyResolver = null, IMetricsClient metricsClient = null, ILoggerFactory loggerFactory = null) : base(dependencyResolver, metricsClient, loggerFactory)
 {
 }
 public static T Time <T>(this IMetricsClient client, Func <T> func, string statName)
 {
     using (client.StartTimer(statName))
         return(func());
 }
Exemple #29
0
 public IncrementCountersAction(IMetricsClient stats)
 {
     _stats = stats;
 }
Exemple #30
0
 public EventUserDescriptionsJob(IQueue <EventUserDescription> queue, IEventRepository eventRepository, IMetricsClient statsClient)
 {
     _queue           = queue;
     _eventRepository = eventRepository;
     _statsClient     = statsClient;
 }
 public IncrementCountersAction(IMetricsClient metricsClient) {
     _metricsClient = metricsClient;
 }
 public EventParserPluginManager(IServiceProvider serviceProvider, AppOptions options, IMetricsClient metricsClient = null, ILoggerFactory loggerFactory = null) : base(serviceProvider, options, metricsClient, loggerFactory)
 {
 }
 public OverageHandler(IOrganizationRepository organizationRepository, IMetricsClient metricsClient) {
     _organizationRepository = organizationRepository;
     _metricsClient = metricsClient;
 }
Exemple #34
0
 public SampleQueueJob(IQueue <SampleQueueWorkItem> queue, IMetricsClient metrics, ILoggerFactory loggerFactory = null) : base(queue, loggerFactory)
 {
     _metrics = metrics ?? NullMetricsClient.Instance;
 }
 public IncrementCountersAction(IMetricsClient metricsClient) {
     _metricsClient = metricsClient;
     ContinueOnError = true;
 }
Exemple #36
0
 public SampleJob(IMetricsClient metrics, ILoggerFactory loggerFactory) : base(loggerFactory)
 {
     _metrics = metrics;
 }
 public IncrementCountersAction(IMetricsClient metricsClient, ILoggerFactory loggerFactory = null) : base(loggerFactory) {
     _metricsClient = metricsClient;
     ContinueOnError = true;
 }
Exemple #38
0
 public static async Task TimeAsync(this IMetricsClient client, Func <Task> action, string name)
 {
     using (client.StartTimer(name))
         await action().AnyContext();
 }
 public StatusController(ICacheClient cacheClient, IMessagePublisher messagePublisher, SystemHealthChecker healthChecker, IQueue <EventPost> eventQueue, IQueue <MailMessage> mailQueue, IQueue <EventNotificationWorkItem> notificationQueue, IQueue <WebHookNotification> webHooksQueue, IQueue <EventUserDescription> userDescriptionQueue, IMetricsClient metricsClient)
 {
     _cacheClient          = cacheClient;
     _messagePublisher     = messagePublisher;
     _healthChecker        = healthChecker;
     _eventQueue           = eventQueue;
     _mailQueue            = mailQueue;
     _notificationQueue    = notificationQueue;
     _webHooksQueue        = webHooksQueue;
     _userDescriptionQueue = userDescriptionQueue;
     _metricsClient        = metricsClient;
 }
 public ThrottleBotsPlugin(ICacheClient cacheClient, IEventRepository eventRepository, IProjectRepository projectRepository, IMetricsClient metricsClient) {
     _cacheClient = cacheClient;
     _metricsClient = metricsClient;
     _eventRepository = eventRepository;
     _projectRepository = projectRepository;
 }
 public SetLocationFromGeoWorkItemHandler(ICacheClient cacheClient, IEventRepository eventRepository, IGeocodeService geocodeService, IMetricsClient metricsClient) {
     _cacheClient = new ScopedCacheClient(cacheClient, "geo");
     _eventRepository = eventRepository;
     _geocodeService = geocodeService;
     _metricsClient = metricsClient;
 }
 public OverageHandler(IOrganizationRepository organizationRepository, IMetricsClient metricsClient, ILogger<OverageHandler> logger) {
     _organizationRepository = organizationRepository;
     _metricsClient = metricsClient;
     _logger = logger;
 }
        public PluginManagerBase(IServiceProvider serviceProvider, AppOptions options, IMetricsClient metricsClient = null, ILoggerFactory loggerFactory = null)
        {
            var type = GetType();

            _metricPrefix  = String.Concat(type.Name.ToLower(), ".");
            _metricsClient = metricsClient ?? new InMemoryMetricsClient(new InMemoryMetricsClientOptions {
                LoggerFactory = loggerFactory
            });
            _logger          = loggerFactory?.CreateLogger(type);
            _serviceProvider = serviceProvider;
            _options         = options;

            Plugins = new SortedList <int, TPlugin>();
            LoadDefaultPlugins();
        }
 public CopySimpleDataToIdxAction(IMetricsClient metricsClient, ILoggerFactory loggerFactory = null) : base(loggerFactory)
 {
     _metricsClient = metricsClient;
 }
 public IncrementCountersAction(IMetricsClient metricsClient)
 {
     _metricsClient = metricsClient;
 }
Exemple #46
0
 public Mailer(IEmailGenerator emailGenerator, IQueue<MailMessage> queue, FormattingPluginManager pluginManager, IMetricsClient metricsClient) {
     _emailGenerator = emailGenerator;
     _queue = queue;
     _pluginManager = pluginManager;
     _metricsClient = metricsClient;
 }
 public EventUserDescriptionsJob(IQueue<EventUserDescription> queue, IEventRepository eventRepository, IMetricsClient metricsClient) {
     _queue = queue;
     _eventRepository = eventRepository;
     _metricsClient = metricsClient;
 }