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 MongoDBStateEntitySaver( IClaptrapIdentity identity, ChannelBatchOperator <StateEntity> .Factory batchOperatorFactory, IDbFactory dbFactory, IMongoDBStateStoreLocatorOptions options, IBatchOperatorContainer batchOperatorContainer) { var locator = options.MongoDBStateStoreLocator; _connectionName = locator.GetConnectionName(identity); _databaseName = locator.GetDatabaseName(identity); _stateCollectionName = locator.GetStateCollectionName(identity); var operatorKey = new BatchOperatorKey() .With(nameof(MongoDBStateEntitySaver)) .With(_connectionName) .With(_databaseName) .With(_stateCollectionName); _batchOperator = (IBatchOperator <StateEntity>)batchOperatorContainer.GetOrAdd( operatorKey, () => batchOperatorFactory.Invoke( new BatchOperatorOptions <StateEntity>(options) { DoManyFunc = (entities, cacheData) => SaveManyCoreMany(dbFactory, entities) })); }
public SQLiteStateEntitySaver( ChannelBatchOperator <StateEntity> .Factory batchOperatorFactory, IClaptrapIdentity identity, ISQLiteDbFactory sqLiteDbFactory, ISQLiteStateStoreOptions options, ISqlTemplateCache sqlTemplateCache, IBatchOperatorContainer batchOperatorContainer) { _sqlTemplateCache = sqlTemplateCache; var locator = options.RelationalStateStoreLocator; var stateTableName = locator.GetStateTableName(identity); _stateTableName = stateTableName; _connectionName = locator.GetConnectionName(identity); var operatorKey = new BatchOperatorKey() .With(nameof(SQLiteStateEntitySaver)) .With(_connectionName) .With(stateTableName); _batchOperator = (IBatchOperator <StateEntity>)batchOperatorContainer.GetOrAdd( operatorKey, () => batchOperatorFactory.Invoke( new BatchOperatorOptions <StateEntity>(options) { DoManyFunc = (entities, cacheData) => SaveManyCoreMany(sqLiteDbFactory, entities, (string[])cacheData ![UpsertSqlKey]),
public InsertValuesMySqlEventEntitySaver( ChannelBatchOperator <EventEntity> .Factory batchOperatorFactory, IClaptrapIdentity identity, IDbFactory dbFactory, IMySqlEventStoreOptions options, IBatchOperatorContainer batchOperatorContainer, ISqlTemplateCache sqlTemplateCache) { var locator = options.RelationalEventStoreLocator; _connectionName = locator.GetConnectionName(identity); _schemaName = locator.GetSchemaName(identity); _eventTableName = locator.GetEventTableName(identity); _dbFactory = dbFactory; _sqlTemplateCache = sqlTemplateCache; var operatorKey = new BatchOperatorKey() .With(nameof(InsertValuesMySqlEventEntitySaver)) .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 PostgreSQLStateEntitySaver( ChannelBatchOperator <StateEntity> .Factory batchOperatorFactory, IBatchOperatorContainer batchOperatorContainer, IDbFactory dbFactory, IClaptrapIdentity identity, IPostgreSQLStateStoreOptions options) { var locator = options.RelationalStateStoreLocator; var(connectionName, schemaName, stateTableName) = locator.GetNames(identity); _connectionName = connectionName; _schemaName = schemaName; _stateTableName = stateTableName; var operatorKey = new BatchOperatorKey() .With(nameof(PostgreSQLStateEntitySaver)) .With(_connectionName) .With(_schemaName) .With(_stateTableName); _batchOperator = (IBatchOperator <StateEntity>)batchOperatorContainer.GetOrAdd( operatorKey, () => batchOperatorFactory.Invoke( new BatchOperatorOptions <StateEntity>(options) { DoManyFunc = (entities, cacheData) => SaveManyCoreMany(dbFactory, entities, (string)cacheData ![UpsertSqlKey]),
public MqSender( string exchange, IReadOnlyDictionary <string, string> topics, IConnection connection, IEventStringSerializer eventStringSerializer, IMessageSerializer messageSerializer, ChannelBatchOperator <IEvent> .Factory batchOperatorFactory, IBatchOperatorContainer batchOperatorContainer, ILogger <MqSender> logger, IOptions <ClaptrapServerOptions> options) { _exchange = exchange; _topics = topics; _connection = connection; _eventStringSerializer = eventStringSerializer; _messageSerializer = messageSerializer; _logger = logger; _options = options; var operatorKey = new BatchOperatorKey() .With(nameof(MqSender)) .With(exchange); _batchOperator = (IBatchOperator <IEvent>)batchOperatorContainer.GetOrAdd( operatorKey, () => batchOperatorFactory.Invoke( new BatchOperatorOptions <IEvent> { BufferTime = TimeSpan.FromMilliseconds(10), BufferCount = 100, DoManyFunc = (events, cacheData) => SendMany(events) })); }
public MySqlStateEntitySaver( ChannelBatchOperator <StateEntity> .Factory batchOperatorFactory, IClaptrapIdentity identity, IDbFactory dbFactory, IRelationalStateStoreLocatorOptions options, ISqlTemplateCache sqlTemplateCache, IBatchOperatorContainer batchOperatorContainer) { var locator = options.RelationalStateStoreLocator; _connectionName = locator.GetConnectionName(identity); _schemaName = locator.GetSchemaName(identity); _tableName = locator.GetStateTableName(identity); _sqlTemplateCache = sqlTemplateCache; var operatorKey = new BatchOperatorKey() .With(nameof(MySqlStateEntitySaver)) .With(_connectionName) .With(_tableName); _batchOperator = (IBatchOperator <StateEntity>)batchOperatorContainer.GetOrAdd( operatorKey, () => batchOperatorFactory.Invoke( new BatchOperatorOptions <StateEntity>(options) { DoManyFunc = (entities, cacheData) => SaveManyCoreMany(dbFactory, entities) })); }
public MongoDBEventEntitySaver( IMongoDBEventStoreOptions options, ChannelBatchOperator <EventEntity> .Factory batchOperatorFactory, IDbFactory dbFactory, IClaptrapIdentity identity, IBatchOperatorContainer batchOperatorContainer) { _dbFactory = dbFactory; var locator = options.MongoDBEventStoreLocator; _connectionName = locator.GetConnectionName(identity); _databaseName = locator.GetDatabaseName(identity); _eventCollectionName = locator.GetEventCollectionName(identity); var operatorKey = new BatchOperatorKey() .With(nameof(MongoDBEventEntitySaver)) .With(_connectionName) .With(_databaseName) .With(_eventCollectionName); _batchOperator = (IBatchOperator <EventEntity>)batchOperatorContainer.GetOrAdd( operatorKey, () => batchOperatorFactory.Invoke( new BatchOperatorOptions <EventEntity>(options) { DoManyFunc = (entities, cacheData) => SaveManyAsync(entities), DoManyFuncName = $"event batch saver for {operatorKey.AsStringKey()}" })); }