Beispiel #1
0
        /// <summary>
        /// Configures Rebus to store saga snapshots in MySQL
        /// </summary>
        public static void StoreInMySql(this StandardConfigurer <ISagaSnapshotStorage> configurer, MySqlSagaSnapshotStorageOptions options, string tableName)
        {
            if (configurer == null)
            {
                throw new ArgumentNullException(nameof(configurer));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (tableName == null)
            {
                throw new ArgumentNullException(nameof(tableName));
            }

            configurer.Register(c =>
            {
                var rebusLoggerFactory = c.Get <IRebusLoggerFactory>();
                var connectionProvider = options.ConnectionProviderFactory(c);
                var snapshotStorage    = new MySqlSagaSnapshotStorage(connectionProvider, tableName, rebusLoggerFactory);

                if (options.EnsureTablesAreCreated)
                {
                    snapshotStorage.EnsureTableIsCreated();
                }

                return(snapshotStorage);
            });
        }
Beispiel #2
0
        /// <summary>
        /// Configures Rebus to store saga snapshots in MySQL
        /// </summary>
        public static void StoreInMySql(this StandardConfigurer <ISagaSnapshotStorage> configurer,
                                        Func <Task <IDbConnection> > connectionFactory, string tableName, bool automaticallyCreateTables = true)
        {
            if (configurer == null)
            {
                throw new ArgumentNullException(nameof(configurer));
            }
            if (connectionFactory == null)
            {
                throw new ArgumentNullException(nameof(connectionFactory));
            }
            if (tableName == null)
            {
                throw new ArgumentNullException(nameof(tableName));
            }

            configurer.Register(c =>
            {
                var rebusLoggerFactory = c.Get <IRebusLoggerFactory>();
                var connectionProvider = new DbConnectionFactoryProvider(connectionFactory);
                var snapshotStorage    = new MySqlSagaSnapshotStorage(connectionProvider, tableName, rebusLoggerFactory);

                if (automaticallyCreateTables)
                {
                    snapshotStorage.EnsureTableIsCreated();
                }

                return(snapshotStorage);
            });
        }
        public ISagaSnapshotStorage Create()
        {
            var snapshotStorage = new MySqlSagaSnapshotStorage(MySqlTestHelper.ConnectionHelper, TableName);

            snapshotStorage.EnsureTableIsCreated();

            return(snapshotStorage);
        }
Beispiel #4
0
        public ISagaSnapshotStorage Create()
        {
            var consoleLoggerFactory = new ConsoleLoggerFactory(true);
            var connectionProvider   = new DbConnectionProvider(MySqlTestHelper.ConnectionString, consoleLoggerFactory);

            var snapperino = new MySqlSagaSnapshotStorage(connectionProvider, TableName, consoleLoggerFactory);

            snapperino.EnsureTableIsCreated();

            return(snapperino);
        }
        /// <summary>
        /// Configures Rebus to use MySQL to store saga data snapshots, using the specified table to store the data
        /// </summary>
        public static void StoreInMySql(this StandardConfigurer <ISagaSnapshotStorage> configurer,
                                        string connectionString, string tableName, bool automaticallyCreateTables = true)
        {
            configurer.Register(c =>
            {
                var sagaStorage = new MySqlSagaSnapshotStorage(new MySqlConnectionHelper(connectionString), tableName);

                if (automaticallyCreateTables)
                {
                    AsyncHelpers.RunSync(() => sagaStorage.EnsureTableIsCreated());
                }

                return(sagaStorage);
            });
        }