public RavenDistributedLock([NotNull] RavenStorage storage, [NotNull] string resource, TimeSpan timeout, RavenStorageOptions options) { storage.ThrowIfNull("storage"); resource.ThrowIfNull("resource"); if ((timeout.TotalSeconds + CommandTimeoutAdditionSeconds) > int.MaxValue) { throw new ArgumentException(string.Format("The timeout specified is too large. Please supply a timeout equal to or less than {0} seconds", int.MaxValue - CommandTimeoutAdditionSeconds), "timeout"); } _storage = storage; _resource = resource; _options = options; if (!AcquiredLocks.Value.ContainsKey(_resource)) { Acquire(_resource, timeout); AcquiredLocks.Value[_resource] = 1; } else { AcquiredLocks.Value[_resource]++; } }
public RavenDistributedLock(RavenStorage storage, string resource, TimeSpan timeout, RavenStorageOptions options) { storage.ThrowIfNull("storage"); if (string.IsNullOrEmpty(resource)) { throw new ArgumentNullException(nameof(resource)); } if (timeout.TotalSeconds > int.MaxValue) { throw new ArgumentException($"The timeout specified is too large. Please supply a timeout equal to or less than {int.MaxValue} seconds", nameof(timeout)); } options.ThrowIfNull("options"); _storage = storage; _resource = resource; _options = options; if (!AcquiredLocks.Value.ContainsKey(_resource) || AcquiredLocks.Value[_resource] == 0) { Acquire(timeout); AcquiredLocks.Value[_resource] = 1; StartHeartBeat(); } else { AcquiredLocks.Value[_resource]++; } }
public RavenConnection(RavenStorage ravenStorage) { ravenStorage.ThrowIfNull("RavenStorage"); _storage = ravenStorage; _options = new RavenStorageOptions(); }
public RavenJobQueue([NotNull] RavenStorage storage, RavenStorageOptions options) { storage.ThrowIfNull("storage"); options.ThrowIfNull("options"); _storage = storage; _options = options; }
public RavenJobQueueProvider([NotNull] RavenStorage storage, [NotNull] RavenStorageOptions options) { storage.ThrowIfNull("storage"); options.ThrowIfNull("options"); _jobQueue = new RavenJobQueue(storage, options); _monitoringApi = new RavenJobQueueMonitoringApi(storage); }
public RavenWriteOnlyTransaction([NotNull] RavenStorage storage) { storage.ThrowIfNull("storage"); _storage = storage; _patchRequests = new List <KeyValuePair <string, PatchRequest> >(); _session = _storage.Repository.OpenSession(); _session.Advanced.UseOptimisticConcurrency = true; }
public RavenFetchedJob( [NotNull] RavenStorage storage, JobQueue jobQueue) { storage.ThrowIfNull("storage"); jobQueue.ThrowIfNull("jobQueue"); _storage = storage; JobId = jobQueue.JobId; Queue = jobQueue.Queue; Id = jobQueue.Id; }
public RavenDistributedLock([NotNull] RavenStorage storage, [NotNull] string resource, TimeSpan timeout) { storage.ThrowIfNull("storage"); resource.ThrowIfNull("resource"); _timeout = timeout; _storage = storage; _resource = resource; // -- Skip some locks if (!_skipLocks.Any(a => _resource.StartsWith(a))) { Lock(); } }
public RavenConnection(RavenStorage storage) { storage.ThrowIfNull("storage"); _storage = storage; }
public RavenJobQueue([NotNull] RavenStorage storage, RavenStorageOptions options) { storage.ThrowIfNull("storage"); options.ThrowIfNull("options"); _storage = storage; _options = options; _queue = new Dictionary <string, BlockingCollection <JobQueue> >(); using (var session = _storage.Repository.OpenSession()) { // -- Queue listening if (options.QueueNames == null) { throw new ArgumentNullException("options.QueueNames", "You should define a set of QueueNames."); } var config = session.Load <RavenJobQueueConfig>("Config/RavenJobQueue") ?? new RavenJobQueueConfig(); foreach (var queue in options.QueueNames) { Console.WriteLine($"Starting on queue: {queue}"); // Creating queue _queue.Add(queue, new BlockingCollection <JobQueue>()); // Create subscription (if not already exist) if (!config.Subscriptions.ContainsKey(queue)) { config.Subscriptions[queue] = _storage.Repository .Subscriptions() .Create <JobQueue>(new SubscriptionCriteria <JobQueue>() { KeyStartsWith = $"{Repository.GetId(typeof(JobQueue), queue)}/", PropertiesMatch = new Dictionary <Expression <Func <JobQueue, object> >, RavenJToken>() { { x => x.FetchedAt, RavenJToken.FromObject(null) } } }); } // Open subscription var subscription = _storage.Repository.Subscriptions().Open <JobQueue>( config.Subscriptions[queue], new SubscriptionConnectionOptions() { IgnoreSubscribersErrors = false, Strategy = SubscriptionOpeningStrategy.ForceAndKeep }); // Subscribe to it subscription.Subscribe(new RepositoryObserver <JobQueue>(a => { Console.WriteLine(a.Id); _queue[queue].Add(a); })); } session.Store(config); session.SaveChanges(); } }
public RavenWriteOnlyTransaction([NotNull] RavenStorage storage) { storage.ThrowIfNull("storage"); _storage = storage; }
public RavenJobQueueMonitoringApi([NotNull] RavenStorage storage) { storage.ThrowIfNull("storage"); _storage = storage; }
public RavenConnection(RavenStorage ravenStorage) { ravenStorage.ThrowIfNull("RavenStorage"); _storage = ravenStorage; }