예제 #1
0
        public async Task OpenAsync(IStorageServiceConfig config)
        {
            connString     = config.DocumentDbConnString;
            databaseId     = config.DocumentDbDatabase;
            collectionId   = config.DocumentDbCollection;
            databaseLink   = $"/dbs/{databaseId}";
            collectionLink = $"/dbs/{databaseId}/colls/{collectionId}";
            options        = new RequestOptions
            {
                OfferThroughput  = config.DocumentDbRUs,
                ConsistencyLevel = ConsistencyLevel.Eventual
            };

            Uri    uri;
            string key;

            ParseConnString(connString, out uri, out key);

            client = new DocumentClient(uri, key, ConnectionPolicy.Default, ConsistencyLevel.Eventual);

            await CreateDatabaseIfNotExistsAsync();
            await CreateCollectionIfNotExistsAsync();
        }
예제 #2
0
 /// <summary>
 /// Loads the configuration.
 /// </summary>
 /// <param name="storageServiceConfig">The storage service configuration.</param>
 public void LoadConfig(IStorageServiceConfig storageServiceConfig)
 {
     this.config = storageServiceConfig;
     CheckAndInit();
 }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StorageService" /> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="config">The configuration.</param>
 /// <exception cref="bS.Sked2.Structure.Base.Exceptions.StorageException">
 /// Error initializing storage. Invalid 'RootPath' provided. - 1
 /// or
 /// Error initializing storage. {e.Message} - 2
 /// </exception>
 /// <exception cref="StorageException">Error initializing storage. Invalid 'RootPath' provided. - 1
 /// or
 /// Error initializing storage. {e.Message} - 2</exception>
 public StorageService(ILogger logger, IStorageServiceConfig config) : base(logger)
 {
     this.config = config;
     CheckAndInit();
 }