public ProjectorServices(ICacheAdapter cache, IMessageBusAdapter bus, ILockProvider lockProvider, IServiceProvider serviceProvider)
 {
     Cache           = cache ?? throw new ArgumentNullException(nameof(cache));
     Bus             = bus ?? throw new ArgumentNullException(nameof(bus));
     LockProvider    = lockProvider ?? throw new ArgumentNullException(nameof(lockProvider));
     ServiceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
 }
 public OrganizationNotificationWorkItemHandler(IOrganizationRepository organizationRepository, IUserRepository userRepository, IMailer mailer, ICacheClient cacheClient, IMessageBus messageBus, ILoggerFactory loggerFactory = null) : base(loggerFactory)
 {
     _organizationRepository = organizationRepository;
     _userRepository         = userRepository;
     _mailer       = mailer;
     _lockProvider = new ThrottlingLockProvider(cacheClient, 1, TimeSpan.FromHours(1));
 }
Ejemplo n.º 3
0
 public CryptoKeyProviderFactory(IConfigurationProvider config, IKmsClientFactory kmsClientFactory, ICryptoKeyStore cryptoKeyStore, ILockProvider lockProvider)
 {
     _config           = config;
     _cryptoKeyStore   = cryptoKeyStore;
     _lockProvider     = lockProvider;
     _kmsClientFactory = kmsClientFactory;
 }
        public override async Task InitializeAsync()
        {
            await base.InitializeAsync();

            _migrationIndex = new MigrationIndex(_configuration);
            await _migrationIndex.DeleteAsync();

            await _migrationIndex.ConfigureAsync();

            var cacheClient = new InMemoryCacheClient();
            var messageBus  = new InMemoryMessageBus();

            _lockProvider             = new CacheLockProvider(cacheClient, messageBus, Log);
            _migrationStateRepository = new MigrationStateRepository(_migrationIndex);

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton <VersionedWithoutVersionMigration>();
            serviceCollection.AddSingleton <Version1Migration>();
            serviceCollection.AddSingleton <Version2Migration>();
            serviceCollection.AddSingleton <Version3Migration>();
            serviceCollection.AddSingleton <FailingMigration>();
            serviceCollection.AddSingleton <FailingResumableMigration>();
            serviceCollection.AddSingleton <RepeatableMigration>();
            _serviceProvider  = serviceCollection.BuildServiceProvider();
            _migrationManager = new MigrationManager(_serviceProvider, _migrationStateRepository, _lockProvider, Log);
        }
Ejemplo n.º 5
0
 public CleanupDataJob(
     IOrganizationRepository organizationRepository,
     OrganizationService organizationService,
     IProjectRepository projectRepository,
     IStackRepository stackRepository,
     IEventRepository eventRepository,
     ITokenRepository tokenRepository,
     IWebHookRepository webHookRepository,
     ICacheClient cacheClient,
     BillingManager billingManager,
     AppOptions appOptions,
     ILoggerFactory loggerFactory = null
     ) : base(loggerFactory)
 {
     _organizationRepository = organizationRepository;
     _organizationService    = organizationService;
     _projectRepository      = projectRepository;
     _stackRepository        = stackRepository;
     _eventRepository        = eventRepository;
     _tokenRepository        = tokenRepository;
     _webHookRepository      = webHookRepository;
     _billingManager         = billingManager;
     _appOptions             = appOptions;
     _lockProvider           = new ThrottlingLockProvider(cacheClient, 1, TimeSpan.FromDays(1));
 }
            public ScheduledJobRunner(Func <IJob> jobFactory, string schedule, ICacheClient cacheClient, ILoggerFactory loggerFactory = null)
            {
                _jobFactory = jobFactory;
                Schedule    = schedule;
                _logger     = loggerFactory?.CreateLogger <ScheduledJobRunner>() ?? NullLogger <ScheduledJobRunner> .Instance;

                _cronSchedule = CronExpression.Parse(schedule);
                if (_cronSchedule == null)
                {
                    throw new ArgumentException("Could not parse schedule.", nameof(schedule));
                }

                var interval = TimeSpan.FromDays(1);

                var nextOccurrence = _cronSchedule.GetNextOccurrence(SystemClock.UtcNow);

                if (nextOccurrence.HasValue)
                {
                    var nextNextOccurrence = _cronSchedule.GetNextOccurrence(nextOccurrence.Value);
                    if (nextNextOccurrence.HasValue)
                    {
                        interval = nextNextOccurrence.Value.Subtract(nextOccurrence.Value);
                    }
                }

                _lockProvider = new ThrottlingLockProvider(cacheClient, 1, interval.Add(interval));

                NextRun = _cronSchedule.GetNextOccurrence(SystemClock.UtcNow);
            }
Ejemplo n.º 7
0
 public static Task <bool> TryUsingAsync(this ILockProvider locker, string name, Action work, TimeSpan?lockTimeout = null, TimeSpan?acquireTimeout = null)
 {
     return(locker.TryUsingAsync(name, () => {
         work();
         return Task.CompletedTask;
     }, lockTimeout, acquireTimeout));
 }
 public CleanupDataJob(
     IOrganizationRepository organizationRepository,
     OrganizationService organizationService,
     IProjectRepository projectRepository,
     IStackRepository stackRepository,
     IEventRepository eventRepository,
     ITokenRepository tokenRepository,
     IWebHookRepository webHookRepository,
     IElasticClient elasticClient,
     ILockProvider lockProvider,
     BillingManager billingManager,
     AppOptions appOptions,
     ILoggerFactory loggerFactory = null
     ) : base(loggerFactory)
 {
     _organizationRepository = organizationRepository;
     _organizationService    = organizationService;
     _projectRepository      = projectRepository;
     _stackRepository        = stackRepository;
     _eventRepository        = eventRepository;
     _tokenRepository        = tokenRepository;
     _webHookRepository      = webHookRepository;
     _billingManager         = billingManager;
     _appOptions             = appOptions;
     _lockProvider           = lockProvider;
 }
Ejemplo n.º 9
0
        public static async Task TestLock(ILockProvider lockProvider)
        {
            var keys = new string[] { "BBFCC95A-2FA1-45DA-A289-FF486C33AFC9", "56FCC95A-2FA1-45DA-A289-FF486C33AFC8" };
            var data = new Dictionary <string, List <int> >(keys.Select(x => new KeyValuePair <string, List <int> >(x, new List <int>())));

            Random ran = new Random();

            await Task.WhenAll(Enumerable.Range(0, 4).Select(async i =>
            {
                var key = keys[i % keys.Length];

                using (var @lock = await lockProvider.GetLock(key))
                {
                    await Task.Delay(ran.Next(100, 300));

                    for (int n = 0; n < 10; n++)
                    {
                        data[key].Add(10 * i + n);
                    }
                }
            }));

            foreach (var kv in data)
            {
                var sorted = kv.Value.OrderBy(x => x).ToList();
                Assert.Equal(sorted, kv.Value);
            }
        }
 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);
 }
Ejemplo n.º 11
0
 public DisposableLock(string name, ILockProvider lockProvider, ILogger logger)
 {
     _duration     = Stopwatch.StartNew();
     _logger       = logger;
     _name         = name;
     _lockProvider = lockProvider;
 }
Ejemplo n.º 12
0
 public CleanupSnapshotJob(ExceptionlessElasticConfiguration configuration, ILockProvider lockProvider, ILoggerFactory loggerFactory)
     : base(configuration.Client, lockProvider, loggerFactory)
 {
     AddRepository(Settings.Current.AppScopePrefix + "ex_organizations", TimeSpan.FromDays(7));
     AddRepository(Settings.Current.AppScopePrefix + "ex_stacks", TimeSpan.FromDays(7));
     AddRepository(Settings.Current.AppScopePrefix + "ex_events", TimeSpan.FromDays(7));
 }
Ejemplo n.º 13
0
 public static Task <bool> TryUsingAsync(this ILockProvider locker, IEnumerable <string> resources, Action work, TimeSpan?timeUntilExpires, TimeSpan?acquireTimeout)
 {
     return(locker.TryUsingAsync(resources, () => {
         work();
         return Task.CompletedTask;
     }, timeUntilExpires, acquireTimeout));
 }
 public AssignToStackAction(IStackRepository stackRepository, FormattingPluginManager formattingPluginManager, IMessagePublisher publisher, AppOptions options, ILockProvider lockProvider, ILoggerFactory loggerFactory = null) : base(options, loggerFactory)
 {
     _stackRepository         = stackRepository ?? throw new ArgumentNullException(nameof(stackRepository));
     _formattingPluginManager = formattingPluginManager ?? throw new ArgumentNullException(nameof(formattingPluginManager));
     _publisher    = publisher;
     _lockProvider = lockProvider;
 }
Ejemplo n.º 15
0
        public ScheduledJobRunner(Func <IJob> jobFactory, string schedule, ICacheClient cacheClient, ILoggerFactory loggerFactory = null)
        {
            _jobFactory = jobFactory;
            Schedule    = schedule;
            _logger     = loggerFactory?.CreateLogger <ScheduledJobRunner>() ?? NullLogger <ScheduledJobRunner> .Instance;

            _runner = new JobRunner(jobFactory, loggerFactory, runContinuous: false);

            _cronSchedule = CrontabSchedule.TryParse(schedule, s => s, e => {
                var ex = e();
                if (_logger.IsEnabled(LogLevel.Error))
                {
                    _logger.LogError(ex, "Error parsing schedule {Schedule}: {Message}", schedule, ex.Message);
                }
                return(null);
            });

            if (_cronSchedule == null)
            {
                throw new ArgumentException("Could not parse schedule.", nameof(schedule));
            }

            var dates    = _cronSchedule.GetNextOccurrences(SystemClock.UtcNow, DateTime.MaxValue).Take(2).ToList();
            var interval = TimeSpan.FromDays(1);

            if (dates.Count == 2)
            {
                interval = dates[1].Subtract(dates[0]);
            }

            _lockProvider = new ThrottlingLockProvider(cacheClient, 1, interval.Add(interval));
        }
 public RuleQueryExecuter(IRepository repository, IRuleExecutionElementFactory <TDocumentType> ruleExecutionElementFactory, [Dependency("MultipleStopwatchCache")] ICache <Tuple <string, string, string, string>, IEnumerable <IRuleExecutionElement <TDocumentType> > > rulesCache, ILockProvider lockProvider)
 {
     _repository = repository;
     _ruleExecutionElementFactory = ruleExecutionElementFactory;
     _rulesCache   = rulesCache;
     _lockProvider = lockProvider;
 }
Ejemplo n.º 17
0
 public RetentionLimitsJob(IOrganizationRepository organizationRepository, IEventRepository eventRepository, ICacheClient cacheClient, AppOptions appOptions, ILoggerFactory loggerFactory = null) : base(loggerFactory)
 {
     _organizationRepository = organizationRepository;
     _eventRepository        = eventRepository;
     _appOptions             = appOptions;
     _lockProvider           = new ThrottlingLockProvider(cacheClient, 1, TimeSpan.FromDays(1));
 }
 public KmsCryptoKeyProvider(IConfigurationProvider config, IKmsClientFactory kmsClientFactory, ICryptoKeyStore cryptoKeyStore, ILockProvider lockProvider)
 {
     _config           = config;
     _cryptoKeyStore   = cryptoKeyStore;
     _lockProvider     = lockProvider;
     _kmsClientFactory = kmsClientFactory;
     _globalLock       = new GlobalLock(lockProvider);
 }
Ejemplo n.º 19
0
 public WebFarmConfiguration(IInstanceDataStore instanceConfigurationStore, ILockProvider lockProvider, IConfigurationProvider configurationProvider)
 {
     _instanceConfigurationStore = instanceConfigurationStore;
     _heartBeatSettings          = configurationProvider.GetGlobalConfigurationAsNameValueCollection(_monotoneIdGenerator, _webfarmSettings, _heartbeatSettings)
                                   ?? new NameValueCollection();
     _globalLock            = new GlobalLock(lockProvider);
     _configurationProvider = configurationProvider;
 }
Ejemplo n.º 20
0
 public SagaServices(IMessageBusAdapter bus, IRepository repository, ILockProvider lockProvider, IPersistentSubscriptionFactory persistentSubscriptionFactory, IServiceProvider serviceProvider)
 {
     Bus          = bus ?? throw new ArgumentNullException(nameof(bus));
     Repository   = repository ?? throw new ArgumentNullException(nameof(repository));
     LockProvider = lockProvider ?? throw new ArgumentNullException(nameof(lockProvider));
     PersistentSubscriptionFactory = persistentSubscriptionFactory ?? throw new ArgumentNullException(nameof(persistentSubscriptionFactory));
     ServiceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
 }
Ejemplo n.º 21
0
 public WithLockingJob(ILoggerFactory loggerFactory) : base(loggerFactory)
 {
     _locker = new CacheLockProvider(new InMemoryCacheClient(new InMemoryCacheClientOptions {
         LoggerFactory = loggerFactory
     }), new InMemoryMessageBus(new InMemoryMessageBusOptions {
         LoggerFactory = loggerFactory
     }), loggerFactory);
 }
 public MigrationManager(IServiceProvider serviceProvider, IMigrationStateRepository migrationStatusRepository, ILockProvider lockProvider, ILoggerFactory loggerFactory)
 {
     _serviceProvider           = serviceProvider;
     _migrationStatusRepository = migrationStatusRepository;
     _lockProvider  = lockProvider;
     _loggerFactory = loggerFactory ?? NullLoggerFactory.Instance;
     _logger        = _loggerFactory.CreateLogger <MigrationManager>();
 }
Ejemplo n.º 23
0
 public static void TryUsingLock(this ILockProvider locker, string name, Action work,
                                 TimeSpan?lockTimeout = null, TimeSpan?acquireTimeout = null)
 {
     try {
         using (locker.AcquireLock(name, lockTimeout, acquireTimeout))
             work();
     } catch (TimeoutException) {}
 }
 public RemoveProjectWorkItemHandler(IProjectRepository projectRepository, IEventRepository eventRepository, IStackRepository stackRepository, ITokenRepository tokenRepository, IWebHookRepository webHookRepository, ICacheClient cacheClient, IMessageBus messageBus, ILoggerFactory loggerFactory = null) : base(loggerFactory) {
     _projectRepository = projectRepository;
     _eventRepository = eventRepository;
     _stackRepository = stackRepository;
     _tokenRepository = tokenRepository;
     _webHookRepository = webHookRepository;
     _lockProvider = new CacheLockProvider(cacheClient, messageBus);
 }
Ejemplo n.º 25
0
 public IndexBase(IElasticConfiguration configuration, string name)
 {
     Name          = name;
     Configuration = configuration;
     _lockProvider = new CacheLockProvider(configuration.Cache, configuration.MessageBus, configuration.LoggerFactory);
     _logger       = configuration.LoggerFactory.CreateLogger(GetType());
     _frozenTypes  = new Lazy <IReadOnlyCollection <IIndexType> >(() => _types.AsReadOnly());
 }
 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);
 }
Ejemplo n.º 27
0
        public ScopedLockProvider(ILockProvider lockProvider, string scope = null)
        {
            UnscopedLockProvider = lockProvider;
            _isLocked            = scope != null;
            Scope = !String.IsNullOrWhiteSpace(scope) ? scope.Trim() : null;

            _keyPrefix = Scope != null?String.Concat(Scope, ":") : String.Empty;
        }
Ejemplo n.º 28
0
 public CleanupSnapshotJob(ExceptionlessElasticConfiguration configuration, ILockProvider lockProvider, ILoggerFactory loggerFactory)
     : base(configuration.Client, lockProvider, loggerFactory)
 {
     _configuration = configuration;
     AddRepository(configuration.Options.ScopePrefix + "organizations", TimeSpan.FromDays(7));
     AddRepository(configuration.Options.ScopePrefix + "stacks", TimeSpan.FromDays(7));
     AddRepository(configuration.Options.ScopePrefix + "events", TimeSpan.FromDays(7));
 }
Ejemplo n.º 29
0
 public DailySummaryJob(IProjectRepository projectRepository, IOrganizationRepository organizationRepository, IUserRepository userRepository, IEventRepository eventRepository, EventStats stats, IMailer mailer, ICacheClient cacheClient, ILoggerFactory loggerFactory = null) : base(loggerFactory) {
     _projectRepository = projectRepository;
     _organizationRepository = organizationRepository;
     _userRepository = userRepository;
     _eventRepository = eventRepository;
     _stats = stats;
     _mailer = mailer;
     _lockProvider = new ThrottlingLockProvider(cacheClient, 1, TimeSpan.FromHours(1));
 }
 public RemoveProjectWorkItemHandler(IProjectRepository projectRepository, IEventRepository eventRepository, IStackRepository stackRepository, ITokenRepository tokenRepository, IWebHookRepository webHookRepository, ICacheClient cacheClient, IMessageBus messageBus, ILoggerFactory loggerFactory = null) : base(loggerFactory)
 {
     _projectRepository = projectRepository;
     _eventRepository   = eventRepository;
     _stackRepository   = stackRepository;
     _tokenRepository   = tokenRepository;
     _webHookRepository = webHookRepository;
     _lockProvider      = new CacheLockProvider(cacheClient, messageBus);
 }
    public static void Ctor_Throws_WhenProviderParameterIsNull()
    {
        ILockProvider provider = null;
        const string  resource = "resource";
        TimeSpan      timeout  = default;

        Assert.Throws <ArgumentNullException>(nameof(provider),
                                              () => new EFCoreLock(provider, resource, timeout));
    }
Ejemplo n.º 32
0
 public CleanupOrphanedDataJob(ExceptionlessElasticConfiguration config, IStackRepository stackRepository, IEventRepository eventRepository, ICacheClient cacheClient, ILockProvider lockProvider, ILoggerFactory loggerFactory = null) : base(loggerFactory)
 {
     _config          = config;
     _elasticClient   = config.Client;
     _stackRepository = stackRepository;
     _eventRepository = eventRepository;
     _cacheClient     = cacheClient;
     _lockProvider    = lockProvider;
 }
Ejemplo n.º 33
0
 public DailySummaryJob(IProjectRepository projectRepository, IOrganizationRepository organizationRepository, IUserRepository userRepository, IStackRepository stackRepository, IEventRepository eventRepository, EventStats stats, IMailer mailer, ILockProvider lockProvider) {
     _projectRepository = projectRepository;
     _organizationRepository = organizationRepository;
     _userRepository = userRepository;
     _stackRepository = stackRepository;
     _eventRepository = eventRepository;
     _stats = stats;
     _mailer = mailer;
     _lockProvider = lockProvider;
 }
Ejemplo n.º 34
0
        public MigrationJobBase(IElasticClient elasticClient, EventUpgraderPluginManager eventUpgraderPluginManager, EventIndex eventIndex, StackIndex stackIndex, IValidator<Stack> stackValidator, IValidator<PersistentEvent> eventValidator, IGeoIPResolver geoIpResolver, ILockProvider lockProvider, ICacheClient cache) {
            _eventUpgraderPluginManager = eventUpgraderPluginManager;
            _mongoDatabase = GetMongoDatabase();
            _eventRepository = new EventMigrationRepository(elasticClient, eventIndex, eventValidator);
            _stackRepository = new StackMigrationRepository(elasticClient, stackIndex, _eventRepository, stackValidator);
            _geoIpResolver = geoIpResolver;
            _lockProvider = lockProvider;
            _cache = cache;

            _batchSize = MigrationSettings.Current.MigrationBatchSize;
        }
 public RemoveStaleAccountsJob(OrganizationRepository organizationRepository,
     IProjectRepository projectRepository,
     IUserRepository userRepository,
     IEventRepository eventRepository,
     IStackRepository stackRepository,
     ILockProvider lockProvider)
 {
     _organizationRepository = organizationRepository;
     _projectRepository = projectRepository;
     _userRepository = userRepository;
     _eventRepository = eventRepository;
     _stackRepository = stackRepository;
     LockProvider = lockProvider;
 }
 public EnforceRetentionLimitsJob(IOrganizationRepository organizationRepository, IEventRepository eventRepository, ILockProvider lockProvider) {
     _organizationRepository = organizationRepository;
     _eventRepository = eventRepository;
     LockProvider = lockProvider;
 }
 public SetProjectIsConfiguredWorkItemHandler(IProjectRepository projectRepository, IEventRepository eventRepository, ICacheClient cacheClient, IMessageBus messageBus, ILoggerFactory loggerFactory = null) : base(loggerFactory) {
     _projectRepository = projectRepository;
     _eventRepository = eventRepository;
     _lockProvider = new CacheLockProvider(cacheClient, messageBus);
 }
 public DownloadGeoIPDatabaseJob(ICacheClient cacheClient, IFileStorage storage, ILoggerFactory loggerFactory = null) : base(loggerFactory) {
     _storage = storage;
     _lockProvider = new ThrottlingLockProvider(cacheClient, 1, TimeSpan.FromDays(1));
 }
 public ProjectMaintenanceWorkItemHandler(IProjectRepository projectRepository, ICacheClient cacheClient, IMessageBus messageBus, ILoggerFactory loggerFactory = null) : base(loggerFactory) {
     _projectRepository = projectRepository;
     _lockProvider = new CacheLockProvider(cacheClient, messageBus);
 }
Ejemplo n.º 40
0
 public RetentionLimitsJob(IOrganizationRepository organizationRepository, IEventRepository eventRepository, ICacheClient cacheClient) {
     _organizationRepository = organizationRepository;
     _eventRepository = eventRepository;
     _lockProvider = new ThrottlingLockProvider(cacheClient, 1, TimeSpan.FromDays(1));
 }
 public DeleteValueWorkItemHandler(ICacheClient cacheClient, IMessagePublisher publisher, ILockProvider lockProvider) {
     _cacheClient = cacheClient;
     _publisher = publisher;
     _lockProvider = lockProvider;
 }
Ejemplo n.º 42
0
 public ThrottledJob(ICacheClient client)
 {
     _locker = new ThrottlingLockProvider(client, 1, TimeSpan.FromMilliseconds(100));
 }
Ejemplo n.º 43
0
 public ElasticConfigurationBase(IQueue<WorkItemData> workItemQueue, ICacheClient cacheClient) {
     _workItemQueue = workItemQueue;
     _lockProvider = new ThrottlingLockProvider(cacheClient, 1, TimeSpan.FromMinutes(1));
 }
Ejemplo n.º 44
0
 public StackWorkItemHandler(IStackRepository stackRepository, IEventRepository eventRepository, ICacheClient cacheClient, IMessageBus messageBus, ILoggerFactory loggerFactory = null) : base(loggerFactory) {
     _stackRepository = stackRepository;
     _eventRepository = eventRepository;
     _lockProvider = new CacheLockProvider(cacheClient, messageBus);
 }
Ejemplo n.º 45
0
 private async Task<bool> DoLockedWorkAsync(ILockProvider locker) {
     return await locker.TryUsingAsync("DoLockedWork", async () => await SystemClock.SleepAsync(500), TimeSpan.FromMinutes(1), TimeSpan.Zero).AnyContext();
 }
 public SnapshotJob(IElasticClient client, ILockProvider lockProvider, ILoggerFactory loggerFactory) {
     _client = client;
     _lockProvider = lockProvider;
     _logger = loggerFactory.CreateLogger(GetType());
 }
Ejemplo n.º 47
0
 public DailyNotificationJob(IProjectRepository projectRepository, IQueue<SummaryNotification> summaryNotificationQueue, ILockProvider lockProvider) {
     _projectRepository = projectRepository;
     _summaryNotificationQueue = summaryNotificationQueue;
     LockProvider = lockProvider;
 }
 public DownloadGeoIPDatabaseJob(ICacheClient cacheClient, IFileStorage storage) {
     _storage = storage;
     _lockProvider = new ThrottlingLockProvider(cacheClient, 1, TimeSpan.FromDays(1));
 }
 public ThrottleBotsWorkItemHandler(IEventRepository eventRepository, ICacheClient cacheClient, IMessageBus messageBus, ILoggerFactory loggerFactory = null) : base(loggerFactory) {
     _eventRepository = eventRepository;
     _lockProvider = new CacheLockProvider(cacheClient, messageBus);
 }
 public ReindexWorkItemHandler(IElasticClient client, ILockProvider lockProvider, ICacheClient cache = null, ILoggerFactory loggerFactory = null) {
     _reindexer = new ElasticReindexer(client, cache, loggerFactory.CreateLogger<ReindexWorkItemHandler>());
     _lockProvider = lockProvider;
     AutoRenewLockOnProgress = true;
 }
 public OrganizationNotificationWorkItemHandler(IOrganizationRepository organizationRepository, IUserRepository userRepository, IMailer mailer, ICacheClient cacheClient, IMessageBus messageBus, ILoggerFactory loggerFactory = null) : base(loggerFactory) {
     _organizationRepository = organizationRepository;
     _userRepository = userRepository;
     _mailer = mailer;
     _lockProvider = new ThrottlingLockProvider(cacheClient, 1, TimeSpan.FromHours(1));
 }
 public OrganizationMaintenanceWorkItemHandler(IOrganizationRepository organizationRepository, ICacheClient cacheClient, IMessageBus messageBus, ILoggerFactory loggerFactory = null) : base(loggerFactory) {
     _organizationRepository = organizationRepository;
     _lockProvider = new CacheLockProvider(cacheClient, messageBus);
 }
Ejemplo n.º 53
0
 public LockHelper(ILockProvider provider)
 {
     LockProvider = provider;
     TimeOut = 10 * 1000;
     SleepTime = 500;
 }
Ejemplo n.º 54
0
 public DisposableLock(string name, ILockProvider lockProvider) {
     _name = name;
     _lockProvider = lockProvider;
 }
Ejemplo n.º 55
0
 public ReindexWorkItemHandler(IElasticClient client, ILockProvider lockProvider) {
     _client = client;
     _lockProvider = lockProvider;
 }
 public QueueEventMigrationsJob(IQueue<EventMigrationBatch> queue, IElasticClient elasticClient, EventUpgraderPluginManager eventUpgraderPluginManager, EventIndex eventIndex, StackIndex stackIndex, IValidator<Stack> stackValidator, IValidator<PersistentEvent> eventValidator, IGeoIPResolver geoIpResolver, ILockProvider lockProvider, ICacheClient cache) : base(elasticClient, eventUpgraderPluginManager, eventIndex, stackIndex, stackValidator, eventValidator, geoIpResolver, lockProvider, cache) {
     _queue = queue;
 }
 public CloseInactiveSessionsJob(IEventRepository eventRepository, ICacheClient cacheClient) {
     _eventRepository = eventRepository;
     _lockProvider = new ThrottlingLockProvider(cacheClient, 1, TimeSpan.FromMinutes(15));
 }
 public CloseInactiveSessionsJob(IEventRepository eventRepository, ICacheClient cacheClient, ILoggerFactory loggerFactory = null) : base(loggerFactory) {
     _eventRepository = eventRepository;
     _cacheClient = cacheClient;
     _lockProvider = new ThrottlingLockProvider(cacheClient, 1, TimeSpan.FromMinutes(1));
 }
Ejemplo n.º 59
0
 public WithLockingJob(ILoggerFactory loggerFactory) : base(loggerFactory) {
     _locker = new CacheLockProvider(new InMemoryCacheClient(loggerFactory), new InMemoryMessageBus(loggerFactory), loggerFactory);
 }
Ejemplo n.º 60
-1
        public RedisQueue(RedisQueueOptions <T> options) : base(options)
        {
            if (options.ConnectionMultiplexer == null)
            {
                throw new ArgumentException("ConnectionMultiplexer is required.");
            }

            options.ConnectionMultiplexer.ConnectionRestored += ConnectionMultiplexerOnConnectionRestored;
            _cache = new RedisCacheClient(new RedisCacheClientOptions {
                ConnectionMultiplexer = options.ConnectionMultiplexer, Serializer = _serializer
            });

            _payloadTimeToLive = GetPayloadTtl();
            _subscriber        = _options.ConnectionMultiplexer.GetSubscriber();

            string listPrefix = _options.ConnectionMultiplexer.IsCluster() ? "{q:" + _options.Name + "}" : $"q:{_options.Name}";

            _queueListName = $"{listPrefix}:in";
            _workListName  = $"{listPrefix}:work";
            _waitListName  = $"{listPrefix}:wait";
            _deadListName  = $"{listPrefix}:dead";

            // min is 1 second, max is 1 minute
            var interval = _options.WorkItemTimeout > TimeSpan.FromSeconds(1) ? _options.WorkItemTimeout.Min(TimeSpan.FromMinutes(1)) : TimeSpan.FromSeconds(1);

            _maintenanceLockProvider = new ThrottlingLockProvider(_cache, 1, interval);

            if (_logger.IsEnabled(LogLevel.Trace))
            {
                _logger.LogTrace("Queue {QueueId} created. Retries: {Retries} Retry Delay: {RetryDelay:g}, Maintenance Interval: {MaintenanceInterval:g}", QueueId, _options.Retries, _options.RetryDelay, interval);
            }
        }