コード例 #1
0
        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();
        }
コード例 #2
0
 public MySqlStorageConnection(MySqlStorage storage, MySqlStorageOptions storageOptions)
 {
     if (storage == null)
     {
         throw new ArgumentNullException("storage");
     }
     _storage        = storage;
     _storageOptions = storageOptions;
 }
コード例 #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;
        }
コード例 #5
0
        public MySqlStorage(string nameOrConnectionString, MySqlStorageOptions options)
        {
            _connectionString = GetConnectionStringFrom(nameOrConnectionString);
            _options          = options;

            Setup setup = new Setup(_connectionString);

            setup.EnsureDatabase();

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

            _existingConnection = existingConnection;
            _options            = new MySqlStorageOptions();

            InitializeQueueProviders();
        }
コード例 #7
0
        public MySqlStorage(MySqlConnection existingConnection, MySqlStorageOptions storageOptions)
        {
            if (existingConnection == null)
            {
                throw new ArgumentNullException("existingConnection");
            }

            _existingConnection = existingConnection;
            _storageOptions     = storageOptions;

            InitializeQueueProviders();
        }
コード例 #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;
        }
コード例 #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",
            };
        }
コード例 #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();
        }
コード例 #11
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 = 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();
        }
コード例 #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));
        }
コード例 #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();
        }
コード例 #14
0
 public MySqlDistributedLock(IDbConnection connection, string resource, TimeSpan timeout, MySqlStorageOptions storageOptions)
     : this(connection, resource, timeout, storageOptions, new CancellationToken())
 {
 }
コード例 #15
0
 public MySqlDistributedLock(MySqlStorage storage, string resource, TimeSpan timeout, MySqlStorageOptions storageOptions)
     : this(storage.CreateAndOpenConnection(), resource, timeout, storageOptions)
 {
     _storage = storage;
 }