Пример #1
0
 public TransactionStorage(
     IServiceProvider serviceProvider,
     IOptions <TransactionOptions> transactionOptions,
     IOptions <MongoConnections> connectionsOptions)
 {
     this.transactionOptions = transactionOptions;
     client      = ClientFactory.CreateClient(connectionsOptions.Value.ConnectionDict[transactionOptions.Value.ConnectionKey]);
     mpscChannel = serviceProvider.GetService <IMpscChannel <AsyncInputEvent <AppendInput, bool> > >();
     serializer  = serviceProvider.GetService <ISerializer>();
     serviceProvider.GetService <IIndexBuildService>().CreateTransactionStorageIndex(client, transactionOptions.Value.Database, transactionOptions.Value.CollectionName).GetAwaiter().GetResult();
     mpscChannel.BindConsumer(BatchProcessing);
 }
Пример #2
0
        public async Task CreateSubTableRecordIndex(ICustomClient client, string database, string collectionName)
        {
            var collection = client.GetCollection <BsonDocument>(database, collectionName);
            var indexList  = await(await collection.Indexes.ListAsync()).ToListAsync();

            if (!indexList.Exists(p => p["name"] == "Name"))
            {
                await collection.Indexes.CreateOneAsync(new CreateIndexModel <BsonDocument>("{'Name':1}", new CreateIndexOptions {
                    Name = "Name", Unique = true
                }));
            }
        }
Пример #3
0
        public async Task CreateTransactionStorageIndex(ICustomClient client, string database, string collectionName)
        {
            var collection = client.GetCollection <BsonDocument>(database, collectionName);
            var indexList  = await(await collection.Indexes.ListAsync()).ToListAsync();

            if (!indexList.Exists(p => p["name"] == "UnitName_TransId"))
            {
                await collection.Indexes.CreateOneAsync(new CreateIndexModel <BsonDocument>("{'UnitName':1,'TransactionId':1}", new CreateIndexOptions {
                    Name = "UnitName_TransId", Unique = true
                }));
            }
        }
Пример #4
0
        public async Task CreateSnapshotArchiveIndex(ICustomClient client, string database, string collectionName)
        {
            var collection = client.GetCollection <BsonDocument>(database, collectionName);
            var indexList  = await(await collection.Indexes.ListAsync()).ToListAsync();

            if (!indexList.Exists(p => p["name"] == "StateId"))
            {
                await collection.Indexes.CreateOneAsync(new CreateIndexModel <BsonDocument>("{'StateId':1}", new CreateIndexOptions {
                    Name = "StateId", Unique = false
                }));
            }
        }
Пример #5
0
        public async Task CreateEventArchiveIndex(ICustomClient client, string database, string collectionName)
        {
            var collection = client.GetCollection <BsonDocument>(database, collectionName);
            var indexList  = await(await collection.Indexes.ListAsync()).ToListAsync();

            if (!indexList.Exists(p => p["name"] == "State_Version") && !indexList.Exists(p => p["name"] == "State_UniqueId"))
            {
                await collection.Indexes.CreateManyAsync(
                    new List <CreateIndexModel <BsonDocument> >() {
                    new CreateIndexModel <BsonDocument>("{'StateId':1,'Version':1}", new CreateIndexOptions {
                        Name = "State_Version", Unique = true
                    }),
                    new CreateIndexModel <BsonDocument>("{'StateId':1,'TypeCode':1,'UniqueId':1}", new CreateIndexOptions {
                        Name = "State_UniqueId", Unique = true
                    })
                }
                    );
            }
        }
Пример #6
0
 public ClassUnderTest(ICustomClient client)
 {
     this.client = client;
 }