Beispiel #1
0
        /// <inheritdoc />
        /// <summary>
        ///     Initializes a new instance of <see cref="T:SqlStreamStore.MySqlStreamStore" />
        /// </summary>
        /// <param name="settings">A settings class to configure this instance.</param>
        public MySqlStreamStore(MySqlStreamStoreSettings settings)
            : base(settings.GetUtcNow, settings.LogName)
        {
            _settings         = settings;
            _createConnection = () =>
            {
                var connection = _settings.ConnectionFactory(_settings.ConnectionString);

                connection.StateChange += ConnectionOnStateChange;

                return(connection);

                void ConnectionOnStateChange(object sender, StateChangeEventArgs e)
                {
                    Logger.Info(e.ToString);
                }
            };
            _streamStoreNotifier = new Lazy <IStreamStoreNotifier>(() =>
            {
                if (_settings.CreateStreamStoreNotifier == null)
                {
                    throw new InvalidOperationException(
                        "Cannot create notifier because supplied createStreamStoreNotifier was null");
                }

                return(settings.CreateStreamStoreNotifier.Invoke(this));
            });
            _schema = new Schema();
        }
 private MySqlStreamStoreFixture(
     ITestOutputHelper testOutputHelper,
     bool createSchema)
 {
     _databaseName    = $"test_{Guid.NewGuid():n}";
     _createSchema    = createSchema;
     _databaseManager = new MySqlDockerDatabaseManager(
         testOutputHelper,
         _databaseName);
     _settings = new MySqlStreamStoreSettings(ConnectionString)
     {
         GetUtcNow = () => GetUtcNow(),
         ScavengeAsynchronously = false
     };
 }
        public MySqlStreamStoreFixture(
            MySqlContainer dockerInstance,
            string databaseName,
            Action onDispose)
        {
            _onDispose   = onDispose;
            DatabaseName = databaseName;
            var connectionString = dockerInstance.ConnectionString;

            _settings = new MySqlStreamStoreSettings(connectionString)
            {
                GetUtcNow = () => GetUtcNow(),
                DisableDeletionTracking     = false,
                AppendDeadlockRetryAttempts = 25
            };
        }
        /// <inheritdoc />
        /// <summary>
        ///     Initializes a new instance of <see cref="T:SqlStreamStore.MySqlStreamStore" />
        /// </summary>
        /// <param name="settings">A settings class to configure this instance.</param>
        public MySqlStreamStore(MySqlStreamStoreSettings settings)
            : base(settings.GetUtcNow, settings.LogName)
        {
            _settings            = settings;
            _createConnection    = () => _settings.ConnectionFactory(_settings.ConnectionString);
            _streamStoreNotifier = new Lazy <IStreamStoreNotifier>(() =>
            {
                if (_settings.CreateStreamStoreNotifier == null)
                {
                    throw new InvalidOperationException(
                        "Cannot create notifier because supplied createStreamStoreNotifier was null");
                }

                return(settings.CreateStreamStoreNotifier.Invoke(this));
            });
            _schema = new Schema();
        }
Beispiel #5
0
        private async Task Init()
        {
            await _databaseManager.CreateDatabase();

            var settings = new MySqlStreamStoreSettings(ConnectionString)
            {
                GetUtcNow = () => GetUtcNow(),
                ScavengeAsynchronously = false
            };

            Store = new MySqlStreamStore(settings);

            if (_createSchema)
            {
                await Store.CreateSchemaIfNotExists();
            }
        }