public SQLiteEventStoreMigration( ILogger <SQLiteEventStoreMigration> logger, DbUpMigration.Factory factory, ISQLiteDbFactory sqLiteDbFactory, IStorageMigrationContainer storageMigrationContainer, IMasterOrSelfIdentity masterOrSelfIdentity, ISQLiteEventStoreOptions options) { var identity = masterOrSelfIdentity.Identity; var storeLocator = options.RelationalEventStoreLocator; var connectionName = storeLocator.GetConnectionName(identity); var eventTableName = storeLocator.GetEventTableName(identity); var migrationOptions = new DbUpMigrationOptions( new[] { Assembly.GetExecutingAssembly() }, fileName => fileName.EndsWith("-event.sql"), new Dictionary <string, string> { { "EventTableName", eventTableName } }, () => { var dbConnection = sqLiteDbFactory.GetConnection(connectionName); var builder = DeployChanges.To.SQLiteDatabase(new SharedConnection(dbConnection)); return(builder, dbConnection); }); var migration = factory.Invoke(logger, migrationOptions); var migrationKey = $"{nameof(SQLiteEventStoreMigration)}_{connectionName}_{eventTableName}"; _migrationTask = storageMigrationContainer.CreateTask(migrationKey, migration); }
public PostgreSQLEventEntitySaver( ChannelBatchOperator <EventEntity> .Factory batchOperatorFactory, IMasterOrSelfIdentity identity, IDbFactory dbFactory, IPostgreSQLEventStoreOptions options, IBatchOperatorContainer batchOperatorContainer) { _dbFactory = dbFactory; var(connectionName, schemaName, eventTableName) = options.RelationalEventStoreLocator.GetNames(identity.Identity); _connectionName = connectionName; _schemaName = schemaName; _eventTableName = eventTableName; var operatorKey = new BatchOperatorKey() .With(nameof(PostgreSQLEventEntitySaver)) .With(_connectionName) .With(_schemaName) .With(_eventTableName); _batchOperator = (IBatchOperator <EventEntity>)batchOperatorContainer.GetOrAdd( operatorKey, () => batchOperatorFactory.Invoke( new BatchOperatorOptions <EventEntity>(options) { DoManyFunc = (entities, cacheData) => SaveManyAsync(entities), DoManyFuncName = $"event batch saver for {operatorKey.AsStringKey()}" })); }
public MongoDBEventEntityLoader( IDbFactory dbFactory, IMasterOrSelfIdentity masterOrSelfIdentity, IMongoDBEventStoreOptions options) { _dbFactory = dbFactory; _masterOrSelfIdentity = masterOrSelfIdentity.Identity; var locator = options.MongoDBEventStoreLocator; _connectionName = locator.GetConnectionName(_masterOrSelfIdentity); _databaseName = locator.GetDatabaseName(_masterOrSelfIdentity); _eventCollectionName = locator.GetEventCollectionName(_masterOrSelfIdentity); }
public PostgreSQLEventEntityLoader( IDbFactory dbFactory, IMasterOrSelfIdentity identity, IRelationalEventStoreLocatorOptions options) { _dbFactory = dbFactory; _masterOrSelfIdentity = identity.Identity; var(connectionName, schemaName, eventTableName) = options.RelationalEventStoreLocator.GetNames(_masterOrSelfIdentity); _connectionName = connectionName; _selectSql = $"SELECT * FROM {schemaName}.{eventTableName} WHERE version >= @startVersion AND version < @endVersion AND claptrap_type_code=@ClaptrapTypeCode AND claptrap_id=@ClaptrapId ORDER BY version"; }
public SQLiteEventEntityLoader( ISQLiteDbFactory sqLiteDbFactory, ISQLiteEventStoreOptions options, IMasterOrSelfIdentity masterOrSelfIdentity) { _sqLiteDbFactory = sqLiteDbFactory; _masterOrSelfIdentity = masterOrSelfIdentity.Identity; var storeLocator = options.RelationalEventStoreLocator; _connectionName = storeLocator.GetConnectionName(_masterOrSelfIdentity); var eventTableName = storeLocator.GetEventTableName(_masterOrSelfIdentity); _selectSql = $"SELECT * FROM {eventTableName} WHERE version >= @startVersion AND version < @endVersion AND claptrap_type_code=@ClaptrapTypeCode AND claptrap_id=@ClaptrapId ORDER BY version"; }
public MySqlEventEntityLoader( IDbFactory dbFactory, IRelationalEventStoreLocatorOptions options, IMasterOrSelfIdentity masterOrSelfIdentity) { _dbFactory = dbFactory; _masterOrSelfIdentity = masterOrSelfIdentity.Identity; var locator = options.RelationalEventStoreLocator; _connectionName = locator.GetConnectionName(_masterOrSelfIdentity); var schemaName = locator.GetSchemaName(_masterOrSelfIdentity); var tableName = locator.GetEventTableName(_masterOrSelfIdentity); _selectSql = $"SELECT * FROM {schemaName}.{tableName} WHERE version >= @startVersion AND version < @endVersion AND claptrap_type_code=@ClaptrapTypeCode AND claptrap_id=@ClaptrapId ORDER BY version"; }
public MongoDBEventStoreMigration( ILogger <MongoDBEventStoreMigration> logger, IDbFactory dbFactory, IMasterOrSelfIdentity masterOrSelfIdentity, IStorageMigrationContainer storageMigrationContainer, IMongoDBEventStoreOptions options) { var locator = options.MongoDBEventStoreLocator; var identity = masterOrSelfIdentity.Identity; var connectionName = locator.GetConnectionName(identity); var databaseName = locator.GetDatabaseName(identity); var eventCollectionName = locator.GetEventCollectionName(identity); var migration = new InternalMongoDBSharedCollectionEventStoreMigration( connectionName, databaseName, eventCollectionName, dbFactory); var migrationKey = $"{nameof(MongoDBEventStoreMigration)}_{connectionName}_{databaseName}_{eventCollectionName}"; _migrationTask = storageMigrationContainer.CreateTask(migrationKey, migration); }