public MySqlStorage(string connectionString, MySqlStorageOptions storageOptions)
        {
            if (connectionString == null)
            {
                throw new ArgumentNullException("connectionString");
            }
            if (storageOptions == null)
            {
                throw new ArgumentNullException("storageOptions");
            }

            if (IsConnectionString(connectionString))
            {
                _connectionString = connectionString;
            }
            else
            {
                throw new ArgumentException(
                          string.Format(
                              "Could not find connection string with name '{0}' in application config file",
                              connectionString));
            }
            _storageOptions = storageOptions;

            if (storageOptions.PrepareSchemaIfNecessary)
            {
                using (var connection = CreateAndOpenConnection())
                {
                    MySqlObjectsInstaller.Install(connection, storageOptions.TablesPrefix);
                }
            }

            InitializeQueueProviders();
        }
Exemple #2
0
 public MySqlStorageConnection(MySqlStorage storage, MySqlStorageOptions storageOptions)
 {
     if (storage == null)
     {
         throw new ArgumentNullException("storage");
     }
     _storage        = storage;
     _storageOptions = storageOptions;
 }
Exemple #3
0
        public CountersAggregator(MySqlStorage storage, MySqlStorageOptions storageOptions)
        {
            if (storage == null)
            {
                throw new ArgumentNullException("storage");
            }

            _storage        = storage;
            _storageOptions = storageOptions;
        }
        public MySqlWriteOnlyTransaction(ElasticStorage.ElasticStorage storage, MySqlStorageOptions storageOptions)
        {
            if (storage == null)
            {
                throw new ArgumentNullException("storage");
            }

            _storage        = storage;
            _storageOptions = storageOptions;
        }
Exemple #5
0
        public MySqlStorage(string nameOrConnectionString, MySqlStorageOptions options)
        {
            _connectionString = GetConnectionStringFrom(nameOrConnectionString);
            _options          = options;

            Setup setup = new Setup(_connectionString);

            setup.EnsureDatabase();

            InitializeQueueProviders();
        }
Exemple #6
0
        internal MySqlStorage(MySqlConnection existingConnection)
        {
            if (existingConnection == null)
            {
                throw new ArgumentNullException("existingConnection");
            }

            _existingConnection = existingConnection;
            _options            = new MySqlStorageOptions();

            InitializeQueueProviders();
        }
        public MySqlStorage(MySqlConnection existingConnection, MySqlStorageOptions storageOptions)
        {
            if (existingConnection == null)
            {
                throw new ArgumentNullException("existingConnection");
            }

            _existingConnection = existingConnection;
            _storageOptions     = storageOptions;

            InitializeQueueProviders();
        }
Exemple #8
0
        public MySqlDistributedLock(
            IDbConnection connection, string resource, TimeSpan timeout, MySqlStorageOptions storageOptions, CancellationToken cancellationToken)
        {
            Logger.TraceFormat("MySqlDistributedLock resource={0}, timeout={1}", resource, timeout);

            _storageOptions    = storageOptions;
            _resource          = resource;
            _timeout           = timeout;
            _connection        = connection;
            _cancellationToken = cancellationToken;
            _start             = DateTime.UtcNow;
        }
Exemple #9
0
        public ExpirationManager(ElasticStorage.ElasticStorage storage, MySqlStorageOptions storageOptions)
        {
            _storage        = storage ?? throw new ArgumentNullException("storage");
            _storageOptions = storageOptions ?? throw new ArgumentNullException(nameof(storageOptions));

            _processedTables = new[]
            {
                $"{storageOptions.TablesPrefix}AggregatedCounter",
                $"{storageOptions.TablesPrefix}Job",
                $"{storageOptions.TablesPrefix}List",
                $"{storageOptions.TablesPrefix}Set",
                $"{storageOptions.TablesPrefix}Hash",
            };
        }
Exemple #10
0
        public MySqlStorage(string nameOrConnectionString, MySqlStorageOptions options)
        {
            if (nameOrConnectionString == null)
            {
                throw new ArgumentNullException("nameOrConnectionString");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            if (IsConnectionString(nameOrConnectionString))
            {
                _connectionString = nameOrConnectionString;
            }
            else if (IsConnectionStringInConfiguration(nameOrConnectionString))
            {
                _connectionString = ConfigurationManager.ConnectionStrings[nameOrConnectionString].ConnectionString;
            }
            else
            {
                throw new ArgumentException(
                          string.Format(
                              "Could not find connection string with name '{0}' in application config file",
                              nameOrConnectionString));
            }

            /*if (!_connectionString.Contains("Use Affected Rows"))
             * {
             *  _connectionString = _connectionString.TrimEnd(' ', ';') + ";Use Affected Rows=true";
             * }*/
            _options = options;

            if (options.PrepareSchemaIfNecessary)
            {
                using (var connection = CreateAndOpenConnection())
                {
                    MySqlObjectsInstaller.Install(connection);
                }
            }

            InitializeQueueProviders();
        }
        public MySqlStorage(string nameOrConnectionString, MySqlStorageOptions options)
        {
            if (nameOrConnectionString == null)
            {
                throw new ArgumentNullException("nameOrConnectionString");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            if (IsConnectionString(nameOrConnectionString))
            {
                _connectionString = ApplyAllowUserVariablesProperty(nameOrConnectionString);
            }
            else if (IsConnectionStringInConfiguration(nameOrConnectionString))
            {
                _connectionString =
                    ApplyAllowUserVariablesProperty(
                        ConfigurationManager.ConnectionStrings[nameOrConnectionString].ConnectionString);
            }
            else
            {
                throw new ArgumentException(
                          string.Format(
                              "Could not find connection string with name '{0}' in application config file",
                              nameOrConnectionString));
            }
            _options = options;

            if (options.PrepareSchemaIfNecessary)
            {
                using (var connection = CreateAndOpenConnection())
                {
                    MySqlObjectsInstaller.Install(connection);
                }
            }

            InitializeQueueProviders();
        }
Exemple #12
0
        public static IGlobalConfiguration <MySqlStorage> UseMySqlStorage(
            [NotNull] this IGlobalConfiguration configuration,
            [NotNull] string nameOrConnectionString,
            [NotNull] MySqlStorageOptions options)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            if (nameOrConnectionString == null)
            {
                throw new ArgumentNullException("nameOrConnectionString");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            var storage = new MySqlStorage(nameOrConnectionString, options);

            return(configuration.UseStorage(storage));
        }
Exemple #13
0
        public MySqlStorage(string nameOrConnectionString, MySqlStorageOptions options)
        {
            if (nameOrConnectionString == null)
            {
                throw new ArgumentNullException("nameOrConnectionString");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            _connectionString = ApplyAllowUserVariablesProperty(nameOrConnectionString);
            _options          = options;

            if (options.PrepareSchemaIfNecessary)
            {
                using (var connection = CreateAndOpenConnection())
                {
                    MySqlObjectsInstaller.Install(connection);
                }
            }

            InitializeQueueProviders();
        }
Exemple #14
0
 public MySqlDistributedLock(IDbConnection connection, string resource, TimeSpan timeout, MySqlStorageOptions storageOptions)
     : this(connection, resource, timeout, storageOptions, new CancellationToken())
 {
 }
Exemple #15
0
 public MySqlDistributedLock(MySqlStorage storage, string resource, TimeSpan timeout, MySqlStorageOptions storageOptions)
     : this(storage.CreateAndOpenConnection(), resource, timeout, storageOptions)
 {
     _storage = storage;
 }