public void Initialize( AsaOutputStorageType outputStorageType, CosmosDbTableConfiguration config) { this.storageType = outputStorageType; this.cosmosDbConfig = config; this.initialized = true; }
/// <summary>Read storage configuration, depending on the storage type</summary> /// <param name="configData">Raw configuration data</param> /// <param name="tableName">Name of the table</param> /// <param name="storageType">Type of storage, e.g. CosmosDbSql</param> private static CosmosDbTableConfiguration GetAsaOutputStorageConfig( IConfigData configData, string tableName, AsaOutputStorageType storageType) { string prefix; // All tables have the same configuration block, with a different prefix switch (tableName) { case MESSAGES: prefix = MESSAGES_KEY; break; case ALARMS: prefix = ALARMS_KEY; break; default: throw new ArgumentOutOfRangeException("Unknown table " + tableName); } // If the table is on CosmosDb, read the configuration parameters if (storageType == AsaOutputStorageType.CosmosDbSql) { var consistency = configData.GetString(prefix + COSMOSDBSQL_CONSISTENCY_KEY); if (!Enum.TryParse <ConsistencyLevel>(consistency, true, out var consistencyLevel)) { consistencyLevel = ConsistencyLevel.Eventual; } return(new CosmosDbTableConfiguration { Api = CosmosDbApi.Sql, ConnectionString = configData.GetString(prefix + COSMOSDBSQL_CONNSTRING_KEY), Database = configData.GetString(prefix + COSMOSDBSQL_DATABASE_KEY), Collection = configData.GetString(prefix + COSMOSDBSQL_COLLECTION_KEY), ConsistencyLevel = consistencyLevel, RUs = configData.GetInt(prefix + COSMOSDBSQL_RUS_KEY), }); } // If another storage type is added, add a similar block here, // and change the output type to allow multiple types. Not needed now. return(null); }