Inheritance: JobStorage
Exemplo n.º 1
0
        public RavenConnection(RavenStorage ravenStorage)
        {
            ravenStorage.ThrowIfNull("RavenStorage");

            _storage = ravenStorage;
            _options = new RavenStorageOptions();
        }
Exemplo n.º 2
0
        public RavenJobQueue([NotNull] RavenStorage storage, RavenStorageOptions options)
        {
            storage.ThrowIfNull("storage");
            options.ThrowIfNull("options");

            _storage = storage;
            _options = options;
            _queue = new BlockingCollection<string>();

            using (var session = _storage.Repository.OpenSession()) {
                var missed = session.Advanced.LoadStartingWith<JobQueue>(Repository.GetId(typeof(JobQueue), ""));
                foreach (var miss in missed) {
                    _queue.Add(miss.Id);
                }
            }

            // -- Queue listening
            if (options.QueueNames == null) {
                Console.WriteLine("Starting on ALL Queue's, this is not recommended, please specify using RavenStorageOptions. Use an empty IEnumerable (such as List<string> or string[0]) to not listen to any queue.");
                _storage.Repository.DocumentChange(typeof(JobQueue), QueueFiller);
            } else {
                foreach (var queue in options.QueueNames) {
                    Console.WriteLine("Starting on queue: {0}", queue);
                    _storage.Repository.DocumentChange(typeof(JobQueue), queue, QueueFiller);
                }
            }
        }
Exemplo n.º 3
0
        public RavenConnection(RavenStorage ravenStorage, RavenStorageOptions options)
            : this(ravenStorage)
        {
            options.ThrowIfNull("options");

            _storage = ravenStorage;
            _options = options;
        }
Exemplo n.º 4
0
        public RavenJobQueue([NotNull] RavenStorage storage, RavenStorageOptions options)
        {
            storage.ThrowIfNull("storage");
            options.ThrowIfNull("options");

            _storage = storage;
            _options = options;
        }
        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 static IGlobalConfiguration<RavenStorage> UseEmbeddedRavenStorage(this IGlobalConfiguration configuration)
        {
            configuration.ThrowIfNull("configuration");

            Repository.Embedded = true;

            var storage = new RavenStorage();

            return configuration.UseStorage(storage);
        }
        public static IGlobalConfiguration<RavenStorage> UseRavenStorage(this IGlobalConfiguration configuration, string connectionString)
        {
            configuration.ThrowIfNull("configuration");
            connectionString.ThrowIfNull("connectionString");

            Repository.ConnectionString = connectionString;

            var storage = new RavenStorage();

            return configuration.UseStorage(storage);
        }
        public static IGlobalConfiguration <RavenStorage> UseRavenStorage(this IGlobalConfiguration configuration, string connectionString)
        {
            configuration.ThrowIfNull("configuration");
            connectionString.ThrowIfNull("connectionString");

            var config = new RepositoryConfig()
            {
                ConnectionStringName = connectionString
            };
            var storage = new RavenStorage(config);

            return(configuration.UseStorage(storage));
        }
Exemplo n.º 9
0
        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 static IGlobalConfiguration<RavenStorage> UseRavenStorage(this IGlobalConfiguration configuration, string connectionUrl, string database)
        {
            configuration.ThrowIfNull("configuration");
            connectionUrl.ThrowIfNull("connectionUrl");
            database.ThrowIfNull("database");

            if (!connectionUrl.StartsWith("http")) {
                throw new ArgumentException("Connection Url must begin with http or https!");
            }

            Repository.ConnectionUrl = connectionUrl;
            Repository.DefaultDatabase = database;

            var storage = new RavenStorage();

            return configuration.UseStorage(storage);
        }
        public static IGlobalConfiguration <RavenStorage> UseRavenStorage(this IGlobalConfiguration configuration, string connectionUrl, string database)
        {
            configuration.ThrowIfNull("configuration");
            connectionUrl.ThrowIfNull("connectionUrl");
            database.ThrowIfNull("database");

            if (!connectionUrl.StartsWith("http"))
            {
                throw new ArgumentException("Connection Url must begin with http or https!");
            }

            var config = new RepositoryConfig()
            {
                ConnectionUrl = connectionUrl,
                Database      = database
            };
            var storage = new RavenStorage(config);

            return(configuration.UseStorage(storage));
        }
        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 RavenJobQueueMonitoringApi([NotNull] RavenStorage storage)
        {
            storage.ThrowIfNull("storage");

            _storage = storage;
        }
Exemplo n.º 15
0
        public RavenStorageMonitoringApi([NotNull] RavenStorage storage)
        {
            storage.ThrowIfNull("storage");

            _storage = storage;
        }
        public RavenWriteOnlyTransaction([NotNull] RavenStorage storage)
        {
            storage.ThrowIfNull("storage");

            _storage = storage;
        }
        public static IGlobalConfiguration <RavenStorage> UseRavenStorage(this IGlobalConfiguration configuration, RavenStorage storage)
        {
            storage.ThrowIfNull("storage");

            return(configuration.UseStorage(storage));
        }
Exemplo n.º 18
0
        public RavenConnection(RavenStorage ravenStorage)
        {
            ravenStorage.ThrowIfNull("RavenStorage");

            _storage = ravenStorage;
        }