internal CosmosStore(ICosmonautClient cosmonautClient, string databaseName, string overriddenCollectionName, IDatabaseCreator databaseCreator = null, ICollectionCreator collectionCreator = null, bool scaleable = false) { CollectionName = overriddenCollectionName; DatabaseName = databaseName; CosmonautClient = cosmonautClient ?? throw new ArgumentNullException(nameof(cosmonautClient)); Settings = new CosmosStoreSettings(databaseName, cosmonautClient.DocumentClient.ServiceEndpoint.ToString(), string.Empty, cosmonautClient.DocumentClient.ConnectionPolicy, scaleCollectionRUsAutomatically: scaleable); if (Settings.InfiniteRetries) { CosmonautClient.DocumentClient.SetupInfiniteRetries(); } if (string.IsNullOrEmpty(Settings.DatabaseName)) { throw new ArgumentNullException(nameof(Settings.DatabaseName)); } _collectionCreator = collectionCreator ?? new CosmosCollectionCreator(CosmonautClient); _databaseCreator = databaseCreator ?? new CosmosDatabaseCreator(CosmonautClient); _cosmosScaler = new CosmosScaler <TEntity>(this); InitialiseCosmosStore(); }
public static IServiceCollection AddCosmosStore <TEntity>(this IServiceCollection services, ICosmonautClient cosmonautClient, string databaseName, string overriddenCollectionName = "") where TEntity : class { services.AddSingleton <ICosmosStore <TEntity> >(x => new CosmosStore <TEntity>(cosmonautClient, databaseName, overriddenCollectionName)); return(services); }
public CosmosStoreTests() { _cosmonautClient = new CosmonautClient(_emulatorUri, _emulatorKey, _connectionPolicy); var serviceCollection = new ServiceCollection(); AddCosmosStores(serviceCollection); _serviceProvider = serviceCollection.BuildServiceProvider(); }
public void AddClient(ICosmonautClient client) { var cosmosAccountEndpoint = client.DocumentClient.ServiceEndpoint.OriginalString.TrimEnd('/'); if (!CosmonautClients.ContainsKey(cosmosAccountEndpoint)) { CosmonautClients.Add(cosmosAccountEndpoint, client); } }
public CosmosStore(ICosmonautClient cosmonautClient, string databaseName, string overriddenCollectionName) : this(cosmonautClient, databaseName, overriddenCollectionName, new CosmosDatabaseCreator(cosmonautClient), new CosmosCollectionCreator(cosmonautClient)) { }
public UnitTest_PersistedGrantStore( DatabaseInitializer <UnitTest_PersistedGrantStore> databaseInitializer, ICosmonautClient cosmonautClient, ICosmosStore <PersistedGrantEntity> persistedGrantCosmosStore, IPersistedGrantStore persistedGrantStore) { _databaseInitializer = databaseInitializer; _cosmonautClient = cosmonautClient; _persistedGrantCosmosStore = persistedGrantCosmosStore; _persistedGrantStore = persistedGrantStore; }
public UnitTest_ResourceStore( DatabaseInitializer <UnitTest_ResourceStore> databaseInitializer, ICosmonautClient cosmonautClient, ICosmosStore <ApiResourceEntity> apiResourceCosmosStore, IFullResourceStore resourceStore) { _databaseInitializer = databaseInitializer; _cosmonautClient = cosmonautClient; _apiResourceCosmosStore = apiResourceCosmosStore; _resourceStore = resourceStore; }
public UnitTest_CacheItemCosmosStore( DatabaseInitializer <UnitTest_CacheItemCosmosStore> databaseInitializer, ICosmonautClient cosmonautClient, ICosmosStore <CacheEntity> cosmosStore, ICache <CacheItem> cache, ICacheStore <CacheItem> cacheStore) { _databaseInitializer = databaseInitializer; _cache = cache; _cosmosStore = cosmosStore; _cosmonautClient = cosmonautClient; _cacheStore = cacheStore; }
public CosmosStore(CosmosStoreSettings settings, string overriddenCollectionName) { Settings = settings ?? throw new ArgumentNullException(nameof(settings)); DatabaseName = settings.DatabaseName; var documentClient = DocumentClientFactory.CreateDocumentClient(settings); CosmonautClient = new CosmonautClient(documentClient, Settings.InfiniteRetries); if (string.IsNullOrEmpty(Settings.DatabaseName)) { throw new ArgumentNullException(nameof(Settings.DatabaseName)); } _collectionCreator = new CosmosCollectionCreator(CosmonautClient); _databaseCreator = new CosmosDatabaseCreator(CosmonautClient); InitialiseCosmosStore(overriddenCollectionName); }
public CosmonautClientTests() { _cosmonautClient = new CosmonautClient(_emulatorUri, _emulatorKey, new ConnectionPolicy { ConnectionProtocol = Protocol.Tcp, ConnectionMode = ConnectionMode.Direct }); _cosmonautClient.CreateDatabaseAsync(new Database { Id = _databaseId }).GetAwaiter().GetResult(); _cosmonautClient.CreateCollectionAsync(_databaseId, new DocumentCollection { Id = _collectionName }).GetAwaiter().GetResult(); }
public CosmonautClientTests() { _cosmonautClient = new CosmonautClient(_emulatorUri, _emulatorKey, new ConnectionPolicy { ConnectionProtocol = Protocol.Tcp, ConnectionMode = ConnectionMode.Direct }); _cosmonautClient.CreateDatabaseAsync(new Database { Id = _databaseId }).GetAwaiter().GetResult(); _cosmonautClient.CreateCollectionAsync(_databaseId, new DocumentCollection { Id = _collectionName, IndexingPolicy = new IndexingPolicy(new RangeIndex(DataType.Number, -1), new RangeIndex(DataType.String, -1)) }).GetAwaiter().GetResult(); }
internal CosmosStore(ICosmonautClient cosmonautClient, string databaseName, string overriddenCollectionName, IDatabaseCreator databaseCreator = null, ICollectionCreator collectionCreator = null) { DatabaseName = databaseName; CosmonautClient = cosmonautClient ?? throw new ArgumentNullException(nameof(cosmonautClient)); Settings = new CosmosStoreSettings(databaseName, cosmonautClient.DocumentClient.ServiceEndpoint.ToString(), string.Empty, cosmonautClient.DocumentClient.ConnectionPolicy); if (Settings.InfiniteRetries) { CosmonautClient.DocumentClient.SetupInfiniteRetries(); } if (string.IsNullOrEmpty(Settings.DatabaseName)) { throw new ArgumentNullException(nameof(Settings.DatabaseName)); } _collectionCreator = collectionCreator ?? new CosmosCollectionCreator(CosmonautClient); _databaseCreator = databaseCreator ?? new CosmosDatabaseCreator(CosmonautClient); InitialiseCosmosStore(overriddenCollectionName); }
public CosmosProvisioningTests() { _cosmonautClient = new CosmonautClient(_emulatorUri, _emulatorKey, _connectionPolicy); }
public CosmosDatabaseCreator(ICosmonautClient cosmonautClient) { _cosmonautClient = cosmonautClient; }
public CosmosDatabaseCreator(IDocumentClient documentClient) { _cosmonautClient = new CosmonautClient(documentClient); }
public CosmosStore(ICosmonautClient cosmonautClient, string databaseName) : this(cosmonautClient, databaseName, string.Empty, new CosmosDatabaseCreator(cosmonautClient), new CosmosCollectionCreator(cosmonautClient)) { }
public CosmosCollectionCreator(ICosmonautClient cosmonautClient) { _cosmonautClient = cosmonautClient; }
public CosmosCollectionCreator(IDocumentClient documentClient) { _cosmonautClient = new CosmonautClient(documentClient); }
public CosmosDbController(IMapper mapper, ICosmonautClient cosmonautClient) { _mapper = mapper; _cosmonautClient = cosmonautClient; }