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)
            }));
        }
示例#2
0
        public MongoDBStateEntityLoader(
            IClaptrapIdentity identity,
            IDbFactory dbFactory,
            IMongoDBStateStoreLocatorOptions options)
        {
            _dbFactory = dbFactory;
            var locator = options.MongoDBStateStoreLocator;

            _connectionName      = locator.GetConnectionName(identity);
            _databaseName        = locator.GetDatabaseName(identity);
            _stateCollectionName = locator.GetStateCollectionName(identity);
            _filter = new ExpressionFilterDefinition <MongoStateEntity>(entity =>
                                                                        entity.claptrap_id == identity.Id &&
                                                                        entity.claptrap_type_code == identity.TypeCode);
        }
示例#3
0
        public MongoDBStateStoreMigration(
            IClaptrapIdentity identity,
            IDbFactory dbFactory,
            IStorageMigrationContainer storageMigrationContainer,
            IMongoDBStateStoreLocatorOptions options)
        {
            var locator             = options.MongoDBStateStoreLocator;
            var connectionName      = locator.GetConnectionName(identity);
            var databaseName        = locator.GetDatabaseName(identity);
            var stateCollectionName = locator.GetStateCollectionName(identity);
            var migration           = new InternalMongoDBSharedCollectionEventStoreMigration(
                connectionName,
                databaseName,
                stateCollectionName,
                dbFactory);
            var migrationKey =
                $"{nameof(MongoDBEventStoreMigration)}_{stateCollectionName}_{databaseName}_{connectionName}";

            _migrationTask = storageMigrationContainer.CreateTask(migrationKey, migration);
        }