public static MongoStorage UseMongoStorage(this IBootstrapperConfiguration configuration, MongoClientSettings mongoClientSettings, string databaseName, MongoStorageOptions options) { MongoStorage storage = new MongoStorage(mongoClientSettings, databaseName, options); configuration.UseStorage(storage); return storage; }
public static MongoStorage UseMongoStorage(this IBootstrapperConfiguration configuration, string connectionString, string databaseName, MongoStorageOptions options) { MongoStorage storage = new MongoStorage(connectionString, databaseName, options); configuration.UseStorage(storage); return storage; }
public MongoConnection(HangfireDbContext database, MongoStorageOptions options, PersistentJobQueueProviderCollection queueProviders) { if (database == null) throw new ArgumentNullException("database"); if (queueProviders == null) throw new ArgumentNullException("queueProviders"); if (options == null) throw new ArgumentNullException("options"); _database = database; _options = options; _queueProviders = queueProviders; }
/// <summary> /// Constructs Job Storage by database connection string, name andoptions /// </summary> /// <param name="connectionString">MongoDB connection string</param> /// <param name="databaseName">Database name</param> /// <param name="options">Storage options</param> public MongoStorage(string connectionString, string databaseName, MongoStorageOptions options) { if (String.IsNullOrWhiteSpace(connectionString) == true) throw new ArgumentNullException("connectionString"); if (String.IsNullOrWhiteSpace(databaseName) == true) throw new ArgumentNullException("databaseName"); if (options == null) throw new ArgumentNullException("options"); _connectionString = connectionString; _databaseName = databaseName; _options = options; Connection = new HangfireDbContext(connectionString, databaseName, options.Prefix); var defaultQueueProvider = new MongoJobQueueProvider(options); QueueProviders = new PersistentJobQueueProviderCollection(defaultQueueProvider); }
/// <summary> /// Creates new MongoDistributedLock /// </summary> /// <param name="resource"></param> /// <param name="timeout"></param> /// <param name="dbContext"></param> /// <param name="storageOptions"></param> /// <returns></returns> public virtual MongoDistributedLock CreateMongoDistributedLock(string resource, TimeSpan timeout, HangfireDbContext dbContext, MongoStorageOptions storageOptions) { return(new MongoDistributedLock($"Hangfire:{resource}", timeout, dbContext, storageOptions, DistributedLockMutex)); }
/// <summary> /// Creates new MongoWriteOnlyTransaction instance /// </summary> /// <param name="dbContext"></param> /// <param name="storageOptions"></param> /// <returns></returns> public virtual MongoWriteOnlyTransaction CreateMongoWriteOnlyTransaction(HangfireDbContext dbContext, MongoStorageOptions storageOptions) { return(new MongoWriteOnlyTransaction(dbContext, storageOptions)); }
/// <summary> /// Creates MongoConnection instance /// </summary> /// <param name="dbContext"></param> /// <param name="storageOptions"></param> /// <returns></returns> public virtual MongoConnection CreateMongoConnection(HangfireDbContext dbContext, MongoStorageOptions storageOptions) { return(new MongoConnection(dbContext, storageOptions)); }
/// <summary> /// Creates MongoJobFetcher instance /// </summary> /// <param name="dbContext"></param> /// <param name="storageOptions"></param> /// <returns></returns> public virtual MongoJobFetcher CreateMongoJobFetcher(HangfireDbContext dbContext, MongoStorageOptions storageOptions) { return(new MongoJobFetcher(dbContext, storageOptions, JobQueueSemaphore)); }
/// <summary> /// Creates MongoExpirationManager instance /// </summary> /// <param name="dbContext"></param> /// <param name="storageOptions"></param> /// <returns></returns> public virtual MongoExpirationManager CreateMongoExpirationManager(HangfireDbContext dbContext, MongoStorageOptions storageOptions) { return(new MongoExpirationManager(dbContext, storageOptions)); }
/// <summary> /// Constructs expiration manager with one hour checking interval /// </summary> /// <param name="dbContext">MongoDB storage</param> /// <param name="options"></param> public MongoExpirationManager(HangfireDbContext dbContext, MongoStorageOptions options) { _dbContext = dbContext; _options = options; _checkInterval = options.JobExpirationCheckInterval; }
public MongoWriteOnlyTransaction(HangfireDbContext database, PersistentJobQueueProviderCollection queueProviders, MongoStorageOptions storageOptions) { _database = database ?? throw new ArgumentNullException(nameof(database)); _queueProviders = queueProviders ?? throw new ArgumentNullException(nameof(queueProviders)); _storageOptions = storageOptions ?? throw new ArgumentNullException(nameof(storageOptions)); }
/// <summary> /// Constructs Job Storage by Mongo client settings, name and options /// </summary> /// <param name="mongoClientSettings">Client settings for MongoDB</param> /// <param name="databaseName">Database name</param> /// <param name="storageOptions">Storage options</param> public MongoStorage(MongoClientSettings mongoClientSettings, string databaseName, MongoStorageOptions storageOptions) { if (mongoClientSettings == null) { throw new ArgumentNullException(nameof(mongoClientSettings)); } if (string.IsNullOrWhiteSpace(databaseName)) { throw new ArgumentNullException(nameof(databaseName)); } if (storageOptions == null) { throw new ArgumentNullException(nameof(storageOptions)); } _mongoClientSettings = mongoClientSettings; _databaseName = databaseName; _storageOptions = storageOptions; _dbContext = new HangfireDbContext(mongoClientSettings, databaseName, _storageOptions.Prefix); using (var migrationManager = new MongoMigrationManager(storageOptions, _dbContext)) { migrationManager.Migrate(); } }
public MongoStorage(string connectionString, string databaseName, MongoStorageOptions storageOptions) : this(MongoClientSettings.FromConnectionString(connectionString), databaseName, storageOptions) { }
public MongoWriteOnlyTransaction(HangfireDbContext dbContext, MongoStorageOptions storageOptions) { _storageOptions = storageOptions; DbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); _jobsAddedToQueue = new HashSet <string>(); }
/// <summary> /// Constructs Job Storage by Mongo client settings, name and options /// </summary> /// <param name="mongoClientSettings">Client settings for MongoDB</param> /// <param name="databaseName">Database name</param> /// <param name="storageOptions">Storage options</param> public MongoStorage(MongoClientSettings mongoClientSettings, string databaseName, MongoStorageOptions storageOptions) { if (mongoClientSettings == null) { throw new ArgumentNullException(nameof(mongoClientSettings)); } if (string.IsNullOrWhiteSpace(databaseName)) { throw new ArgumentNullException(nameof(databaseName)); } if (storageOptions == null) { throw new ArgumentNullException(nameof(storageOptions)); } _mongoClientSettings = mongoClientSettings; _databaseName = databaseName; _storageOptions = storageOptions; _dbContext = new HangfireDbContext(mongoClientSettings, databaseName, _storageOptions.Prefix); if (_storageOptions.CheckConnection) { CheckConnection(); } MongoMigrationManager.MigrateIfNeeded(storageOptions, _dbContext.Database); }
/// <summary> /// Constructs Job Storage by Mongo client settings, name and options /// </summary> /// <param name="mongoClientSettings">Client settings for MongoDB</param> /// <param name="databaseName">Database name</param> /// <param name="storageOptions">Storage options</param> public MongoStorage(MongoClientSettings mongoClientSettings, string databaseName, MongoStorageOptions storageOptions) : this(new MongoClient(mongoClientSettings), databaseName, storageOptions) { }
/// <summary> /// Constructs Job Storage by Mongo client settings, name and options /// </summary> /// <param name="mongoClientSettings">Client settings for MongoDB</param> /// <param name="databaseName">Database name</param> /// <param name="options">Storage options</param> public MongoStorage(MongoClientSettings mongoClientSettings, string databaseName, MongoStorageOptions options) { if (mongoClientSettings == null) { throw new ArgumentNullException(nameof(mongoClientSettings)); } if (string.IsNullOrWhiteSpace(databaseName)) { throw new ArgumentNullException(nameof(databaseName)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } _mongoClientSettings = mongoClientSettings; _databaseName = databaseName; _options = options; Connection = new HangfireDbContext(mongoClientSettings, databaseName, options.Prefix); var defaultQueueProvider = new MongoJobQueueProvider(options); QueueProviders = new PersistentJobQueueProviderCollection(defaultQueueProvider); }
/// <summary> /// Constructs Job Storage by Mongo client settings, name and options /// </summary> /// <param name="mongoClientSettings">Client settings for MongoDB</param> /// <param name="databaseName">Database name</param> /// <param name="storageOptions">Storage options</param> public MongoStorage(MongoClientSettings mongoClientSettings, string databaseName, MongoStorageOptions storageOptions) { _mongoClientSettings = mongoClientSettings ?? throw new ArgumentNullException(nameof(mongoClientSettings)); _databaseName = databaseName ?? throw new ArgumentNullException(nameof(databaseName)); _storageOptions = storageOptions ?? throw new ArgumentNullException(nameof(storageOptions)); if (string.IsNullOrWhiteSpace(databaseName)) { throw new ArgumentException("Please state a connection name", nameof(databaseName)); } Connection = new HangfireDbContext(mongoClientSettings, databaseName, _storageOptions.Prefix); var migrationManager = new MongoMigrationManager(storageOptions); migrationManager.Migrate(Connection); var defaultQueueProvider = new MongoJobQueueProvider(_storageOptions); QueueProviders = new PersistentJobQueueProviderCollection(defaultQueueProvider); }