public static IServiceCollection AddCosmosStore <TEntity>(this IServiceCollection services, CosmosStoreSettings settings) where TEntity : class { var documentClient = DocumentClientFactory.CreateDocumentClient(settings); services.AddSingleton <ICosmosStore <TEntity> >(x => new CosmosStore <TEntity>(settings, new CosmosDatabaseCreator(documentClient), new CosmosCollectionCreator(documentClient))); return(services); }
public CosmosClient( Uri endpoint, string authKeyOrResourceToken, ConnectionPolicy connectionPolicy = null, ConsistencyLevel?desiredConsistencyLevel = null, bool infiniteRetrying = true) { DocumentClient = DocumentClientFactory.CreateDocumentClient(endpoint, authKeyOrResourceToken, connectionPolicy, desiredConsistencyLevel); if (infiniteRetrying) { DocumentClient.SetupInfiniteRetries(); } _serializerSettings = DocumentClient.GetJsonSerializerSettingsFromClient(); }
public CosmosStore(CosmosStoreSettings settings, string overriddenCollectionName) { Settings = settings ?? throw new ArgumentNullException(nameof(settings)); DatabaseName = settings.DatabaseName; var documentClient = DocumentClientFactory.CreateDocumentClient(settings); CosmosClient = new CosmosClient(documentClient, Settings.InfiniteRetries); if (string.IsNullOrEmpty(Settings.DatabaseName)) { throw new ArgumentNullException(nameof(Settings.DatabaseName)); } _collectionCreator = new CosmosCollectionCreator(CosmosClient); _databaseCreator = new CosmosDatabaseCreator(CosmosClient); InitialiseCosmosStore(overriddenCollectionName); }
public static ICosmonautClient CreateCosmonautClient(CosmosStoreSettings settings) { return(new CosmonautClient(DocumentClientFactory.CreateDocumentClient(settings))); }