|
6 | 6 | using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Concurrency; |
7 | 7 | using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Diagnostics; |
8 | 8 | using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Runtime; |
| 9 | +using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Storage; |
9 | 10 | using Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.Auth; |
10 | 11 |
|
11 | 12 | // TODO: tests |
@@ -70,6 +71,18 @@ public class Config : IConfig |
70 | 71 | private const string STORAGE_ADAPTER_API_URL_KEY = STORAGE_ADAPTER_KEY + "webservice_url"; |
71 | 72 | private const string STORAGE_ADAPTER_API_TIMEOUT_KEY = STORAGE_ADAPTER_KEY + "webservice_timeout"; |
72 | 73 |
|
| 74 | + private const string MAIN_STORAGE_KEY = APPLICATION_KEY + "Storage:Main:"; |
| 75 | + private const string NODES_STORAGE_KEY = APPLICATION_KEY + "Storage:Nodes:"; |
| 76 | + private const string SIMULATIONS_STORAGE_KEY = APPLICATION_KEY + "Storage:Simulations:"; |
| 77 | + private const string DEVICES_STORAGE_KEY = APPLICATION_KEY + "Storage:Devices:"; |
| 78 | + private const string PARTITIONS_STORAGE_KEY = APPLICATION_KEY + "Storage:Partitions:"; |
| 79 | + |
| 80 | + private const string STORAGE_TYPE_KEY = "type"; |
| 81 | + private const string DOCUMENTDB_CONNECTION_STRING_KEY = "documentdb_connstring"; |
| 82 | + private const string DOCUMENTDB_DATABASE_KEY = "documentdb_database"; |
| 83 | + private const string DOCUMENTDB_COLLECTION_KEY = "documentdb_collection"; |
| 84 | + private const string DOCUMENTDB_RUS_KEY = "documentdb_collection_RUs"; |
| 85 | + |
73 | 86 | private const string LOGGING_KEY = APPLICATION_KEY + "Logging:"; |
74 | 87 | private const string LOGGING_LOGLEVEL_KEY = LOGGING_KEY + "LogLevel"; |
75 | 88 | private const string LOGGING_INCLUDEPROCESSID_KEY = LOGGING_KEY + "IncludeProcessId"; |
@@ -193,7 +206,24 @@ private static IServicesConfig GetServicesConfig(IConfigData configData) |
193 | 206 | IoTHubSdkDeviceClientTimeout = configData.GetOptionalUInt(IOTHUB_SDK_DEVICE_CLIENT_TIMEOUT_KEY), |
194 | 207 | StorageAdapterApiUrl = configData.GetString(STORAGE_ADAPTER_API_URL_KEY), |
195 | 208 | StorageAdapterApiTimeout = configData.GetInt(STORAGE_ADAPTER_API_TIMEOUT_KEY), |
196 | | - TwinReadWriteEnabled = configData.GetBool(TWIN_READ_WRITE_ENABLED_KEY, true) |
| 209 | + TwinReadWriteEnabled = configData.GetBool(TWIN_READ_WRITE_ENABLED_KEY, true), |
| 210 | + MainStorage = GetStorageConfig(configData, MAIN_STORAGE_KEY), |
| 211 | + NodesStorage = GetStorageConfig(configData, NODES_STORAGE_KEY), |
| 212 | + SimulationsStorage = GetStorageConfig(configData, SIMULATIONS_STORAGE_KEY), |
| 213 | + DevicesStorage = GetStorageConfig(configData, DEVICES_STORAGE_KEY), |
| 214 | + PartitionsStorage = GetStorageConfig(configData, PARTITIONS_STORAGE_KEY) |
| 215 | + }; |
| 216 | + } |
| 217 | + |
| 218 | + private static StorageConfig GetStorageConfig(IConfigData configData, string prefix) |
| 219 | + { |
| 220 | + return new StorageConfig |
| 221 | + { |
| 222 | + StorageType = configData.GetString(prefix + STORAGE_TYPE_KEY), |
| 223 | + DocumentDbConnString = configData.GetString(prefix + DOCUMENTDB_CONNECTION_STRING_KEY), |
| 224 | + DocumentDbDatabase = configData.GetString(prefix + DOCUMENTDB_DATABASE_KEY), |
| 225 | + DocumentDbCollection = configData.GetString(prefix + DOCUMENTDB_COLLECTION_KEY), |
| 226 | + DocumentDbRUs = configData.GetInt(prefix + DOCUMENTDB_RUS_KEY) |
197 | 227 | }; |
198 | 228 | } |
199 | 229 |
|
|
0 commit comments