コード例 #1
0
        internal CosmosStore(IDocumentClient documentClient,
                             string databaseName,
                             string authKey,
                             string endpoint,
                             string overriddenCollectionName,
                             IDatabaseCreator databaseCreator     = null,
                             ICollectionCreator collectionCreator = null,
                             bool scaleable = false)
        {
            CollectionName = overriddenCollectionName;
            DatabaseName   = databaseName;
            if (documentClient == null)
            {
                throw new ArgumentNullException(nameof(documentClient));
            }
            var cosmonautClient = new CosmonautClient(documentClient);

            Settings = new CosmosStoreSettings(databaseName, endpoint, authKey, documentClient.ConnectionPolicy,
                                               scaleCollectionRUsAutomatically: scaleable);
            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();
        }
コード例 #2
0
ファイル: CosmosStore.cs プロジェクト: reddy6ue/Cosmonaut
 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();
 }
コード例 #3
0
ファイル: CosmosStore.cs プロジェクト: christophla/Cosmonaut
 internal CosmosStore(IDocumentClient documentClient,
                      string databaseName,
                      IDatabaseCreator databaseCreator,
                      ICollectionCreator collectionCreator)
 {
     DocumentClient = documentClient ?? throw new ArgumentNullException(nameof(documentClient));
     Settings       = new CosmosStoreSettings(databaseName, documentClient.ServiceEndpoint, documentClient.AuthKey.ToString(), documentClient.ConnectionPolicy);
     if (string.IsNullOrEmpty(Settings.DatabaseName))
     {
         throw new ArgumentNullException(nameof(Settings.DatabaseName));
     }
     _databaseCreator   = databaseCreator ?? throw new ArgumentNullException(nameof(databaseCreator));
     _collectionCreator = collectionCreator ?? throw new ArgumentNullException(nameof(collectionCreator));
     InitialiseCosmosStore();
 }
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: CosmosStore.cs プロジェクト: christophla/Cosmonaut
        public CosmosStore(CosmosStoreSettings settings,
                           IDatabaseCreator databaseCreator,
                           ICollectionCreator collectionCreator)
        {
            Settings = settings ?? throw new ArgumentNullException(nameof(settings));
            var endpointUrl = Settings.EndpointUrl ?? throw new ArgumentNullException(nameof(Settings.EndpointUrl));
            var authKey     = Settings.AuthKey ?? throw new ArgumentNullException(nameof(Settings.AuthKey));

            DocumentClient = DocumentClientFactory.CreateDocumentClient(endpointUrl, authKey);
            if (string.IsNullOrEmpty(Settings.DatabaseName))
            {
                throw new ArgumentNullException(nameof(Settings.DatabaseName));
            }
            _collectionCreator = collectionCreator ?? throw new ArgumentNullException(nameof(collectionCreator));
            _databaseCreator   = databaseCreator ?? throw new ArgumentNullException(nameof(databaseCreator));
            InitialiseCosmosStore();
        }
コード例 #6
0
 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);
 }
コード例 #7
0
ファイル: CosmosStore.cs プロジェクト: reddy6ue/Cosmonaut
 public CosmosStore(CosmosStoreSettings settings) : this(settings, string.Empty)
 {
 }
コード例 #8
0
 internal static IDocumentClient CreateDocumentClient(CosmosStoreSettings settings)
 {
     return(new DocumentClient(settings.EndpointUrl, settings.AuthKey, settings.JsonSerializerSettings, settings.ConnectionPolicy ?? ConnectionPolicy.Default, settings.ConsistencyLevel));
 }
コード例 #9
0
 public static IDocumentClient CreateDocumentClient(CosmosStoreSettings settings)
 {
     return(new DocumentClient(settings.EndpointUrl, settings.AuthKey, settings.ConnectionPolicy ?? ConnectionPolicy.Default));
 }