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;
            _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);
                }
            }
        }
        public RavenConnection(RavenStorage ravenStorage, RavenStorageOptions options)
            : this(ravenStorage)
        {
            options.ThrowIfNull("options");

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

            _storage = storage;
            _options = options;
        }
Example #5
0
        /// <summary>
        /// Initializes RavenStorage from the provided SqlServerStorageOptions and either the provided connection
        /// string or the connection string with provided name pulled from the application config file.
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="options"></param>
        /// <exception cref="ArgumentNullException"><paramref name="connectionString"/> argument is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="options"/> argument is null.</exception>
        /// <exception cref="ArgumentException"><paramref name="connectionString"/> argument is neither
        /// a valid Raven connection string nor the name of a connection string in the application
        /// config file.</exception>
        public RavenStorage(RavenStorageOptions options)
        {
            options.ThrowIfNull("options");

            _options = options;

            InitializeQueueProviders();
        }
        /// <summary>
        /// Initializes RavenStorage from the provided SqlServerStorageOptions and either the provided connection
        /// string or the connection string with provided name pulled from the application config file.       
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="options"></param>
        /// <exception cref="ArgumentNullException"><paramref name="connectionString"/> argument is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="options"/> argument is null.</exception>
        /// <exception cref="ArgumentException"><paramref name="connectionString"/> argument is neither 
        /// a valid Raven connection string nor the name of a connection string in the application
        /// config file.</exception>
        public RavenStorage(RavenStorageOptions options)
        {
            options.ThrowIfNull("options");

            _options = options;

            InitializeQueueProviders();
        }
        public static IGlobalConfiguration<RavenStorage> UseEmbeddedRavenStorage(this IGlobalConfiguration configuration, RavenStorageOptions options)
        {
            configuration.ThrowIfNull("configuration");
            options.ThrowIfNull("options");

            Repository.Embedded = true;

            var storage = new RavenStorage(options);

            return configuration.UseStorage(storage);
        }
        public RavenStorage(IRepository repository, RavenStorageOptions options)
        {
            repository.ThrowIfNull("repository");
            options.ThrowIfNull("options");

            _options    = options;
            _repository = repository;

            _repository.Create();

            InitializeQueueProviders();
        }
Example #9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="config"></param>
        /// <param name="options"></param>
        public RavenStorage(RepositoryConfig config, RavenStorageOptions options)
        {
            options.ThrowIfNull("options");

            _options = options;
            _repository = new Repository(config);

            _repository.ExecuteIndexes(new List<AbstractIndexCreationTask>()
            {
                new Hangfire_RavenJobs()
            });

            InitializeQueueProviders();
        }
Example #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="config"></param>
        /// <param name="options"></param>
        public RavenStorage(RepositoryConfig config, RavenStorageOptions options)
        {
            options.ThrowIfNull("options");

            _options    = options;
            _repository = new Repository(config);

            _repository.ExecuteIndexes(new List <AbstractIndexCreationTask>()
            {
                new Hangfire_RavenJobs(),
                new Hangfire_JobQueues()
            });

            InitializeQueueProviders();
        }
Example #11
0
        public RavenStorage(IRepository repository, RavenStorageOptions options)
        {
            repository.ThrowIfNull("repository");
            options.ThrowIfNull("options");

            _options    = options;
            _repository = repository;

            _repository.Create();
            _repository.ExecuteIndexes(new List <AbstractIndexCreationTask>()
            {
                new Hangfire_RavenJobs(),
                new Hangfire_JobQueues(),
                new Hangfire_RavenServers()
            });

            InitializeQueueProviders();
        }
        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]++;
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="config"></param>
 /// <param name="options"></param>
 public RavenStorage(RepositoryConfig config, RavenStorageOptions options)
     : this(new Repository(config), options)
 {
 }
        public static IGlobalConfiguration <RavenStorage> UseRavenStorage(this IGlobalConfiguration configuration, string connectionUrl, string database, RavenStorageOptions options)
        {
            configuration.ThrowIfNull("configuration");
            connectionUrl.ThrowIfNull("connectionUrl");
            database.ThrowIfNull("database");
            options.ThrowIfNull("options");

            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, options);

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

            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(options);

            return configuration.UseStorage(storage);
        }