Example #1
0
        internal async Task <IDocumentClient> InitialiseAsync(IDocumentClient documentClient,
                                                              CosmosDataStoreOptions cosmosDataStoreOptions)
        {
            await documentClient.CreateDatabaseIfNotExistsAsync(new Database { Id = cosmosDataStoreOptions.Database });

            await CreateLockClaimsCollection(documentClient, cosmosDataStoreOptions);

            return(documentClient);
        }
        public CosmosDistributedLockStoreTests()
        {
            _mockDocumentClient = new Mock <IDocumentClient>();
            var mockTelemetry = new Mock <IBigBrother>();

            _options = new CosmosDataStoreOptions
            {
                DistributedLocksCollection = "lockCollection",
                Database = "database"
            };

            _store = new CosmosDistributedLockStore(_mockDocumentClient.Object,
                                                    Options.Create(_options), mockTelemetry.Object);
        }
        public CosmosDbLeaseStoreTests()
        {
            _mockDocumentClient = new Mock <IDocumentClient>();
            _mockTelemetry      = new Mock <IBigBrother>();

            _options = new CosmosDataStoreOptions
            {
                LeasesCollection   = "collection1",
                RequestsCollection = "collection2",
                Database           = "database"
            };

            _store = new CosmosDbLeaseStore(_mockDocumentClient.Object, _mockTelemetry.Object,
                                            Options.Create(_options));
        }
Example #4
0
        private async Task CreateLockClaimsCollection(IDocumentClient documentClient,
                                                      CosmosDataStoreOptions cosmosDataStoreOptions)
        {
            var collectionDefinition = new DocumentCollection
            {
                Id           = cosmosDataStoreOptions.DistributedLocksCollection,
                PartitionKey = new PartitionKeyDefinition
                {
                    Paths = new Collection <string> {
                        "/id"
                    }
                }
            };

            await documentClient.CreateDocumentCollectionIfNotExistsAsync(
                UriFactory.CreateDatabaseUri(cosmosDataStoreOptions.Database),
                collectionDefinition,
                new RequestOptions { OfferThroughput = cosmosDataStoreOptions.OfferThroughput }).ConfigureAwait(false);
        }