* Adding new storage config settings
This commit is contained in:
Peter Felts 2018-08-28 09:53:47 -07:00 коммит произвёл Harleen Thind
Родитель b8dab0315e
Коммит f3fbc220aa
5 изменённых файлов: 101 добавлений и 1 удалений

Просмотреть файл

@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
using System.IO;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Storage;
namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Runtime
{
@ -14,6 +15,11 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Runtime
string StorageAdapterApiUrl { get; }
int StorageAdapterApiTimeout { get; }
bool TwinReadWriteEnabled { get; }
StorageConfig MainStorage { get; }
StorageConfig NodesStorage { get; set; }
StorageConfig SimulationsStorage { get; set; }
StorageConfig DevicesStorage { get; set; }
StorageConfig PartitionsStorage { get; set; }
}
// TODO: test Windows/Linux folder separator
@ -61,6 +67,16 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Runtime
public bool TwinReadWriteEnabled { get; set; }
public StorageConfig MainStorage { get; set; }
public StorageConfig NodesStorage { get; set; }
public StorageConfig SimulationsStorage { get; set; }
public StorageConfig DevicesStorage { get; set; }
public StorageConfig PartitionsStorage { get; set; }
private string NormalizePath(string path)
{
return path

Просмотреть файл

@ -0,0 +1,13 @@
// Copyright (c) Microsoft. All rights reserved.
namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Storage
{
public class StorageConfig
{
public string StorageType { get; set; }
public string DocumentDbConnString { get; set; }
public string DocumentDbDatabase { get; set; }
public string DocumentDbCollection { get; set; }
public int DocumentDbRUs { get; set; }
}
}

Просмотреть файл

@ -6,6 +6,7 @@ using System.IO;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Concurrency;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Diagnostics;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Runtime;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Storage;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.Auth;
// TODO: tests
@ -70,6 +71,18 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.Runtime
private const string STORAGE_ADAPTER_API_URL_KEY = STORAGE_ADAPTER_KEY + "webservice_url";
private const string STORAGE_ADAPTER_API_TIMEOUT_KEY = STORAGE_ADAPTER_KEY + "webservice_timeout";
private const string MAIN_STORAGE_KEY = APPLICATION_KEY + "Storage:Main:";
private const string NODES_STORAGE_KEY = APPLICATION_KEY + "Storage:Nodes:";
private const string SIMULATIONS_STORAGE_KEY = APPLICATION_KEY + "Storage:Simulations:";
private const string DEVICES_STORAGE_KEY = APPLICATION_KEY + "Storage:Devices:";
private const string PARTITIONS_STORAGE_KEY = APPLICATION_KEY + "Storage:Partitions:";
private const string STORAGE_TYPE_KEY = "type";
private const string DOCUMENTDB_CONNECTION_STRING_KEY = "documentdb_connstring";
private const string DOCUMENTDB_DATABASE_KEY = "documentdb_database";
private const string DOCUMENTDB_COLLECTION_KEY = "documentdb_collection";
private const string DOCUMENTDB_RUS_KEY = "documentdb_collection_RUs";
private const string LOGGING_KEY = APPLICATION_KEY + "Logging:";
private const string LOGGING_LOGLEVEL_KEY = LOGGING_KEY + "LogLevel";
private const string LOGGING_INCLUDEPROCESSID_KEY = LOGGING_KEY + "IncludeProcessId";
@ -193,7 +206,24 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.Runtime
IoTHubSdkDeviceClientTimeout = configData.GetOptionalUInt(IOTHUB_SDK_DEVICE_CLIENT_TIMEOUT_KEY),
StorageAdapterApiUrl = configData.GetString(STORAGE_ADAPTER_API_URL_KEY),
StorageAdapterApiTimeout = configData.GetInt(STORAGE_ADAPTER_API_TIMEOUT_KEY),
TwinReadWriteEnabled = configData.GetBool(TWIN_READ_WRITE_ENABLED_KEY, true)
TwinReadWriteEnabled = configData.GetBool(TWIN_READ_WRITE_ENABLED_KEY, true),
MainStorage = GetStorageConfig(configData, MAIN_STORAGE_KEY),
NodesStorage = GetStorageConfig(configData, NODES_STORAGE_KEY),
SimulationsStorage = GetStorageConfig(configData, SIMULATIONS_STORAGE_KEY),
DevicesStorage = GetStorageConfig(configData, DEVICES_STORAGE_KEY),
PartitionsStorage = GetStorageConfig(configData, PARTITIONS_STORAGE_KEY)
};
}
private static StorageConfig GetStorageConfig(IConfigData configData, string prefix)
{
return new StorageConfig
{
StorageType = configData.GetString(prefix + STORAGE_TYPE_KEY),
DocumentDbConnString = configData.GetString(prefix + DOCUMENTDB_CONNECTION_STRING_KEY),
DocumentDbDatabase = configData.GetString(prefix + DOCUMENTDB_DATABASE_KEY),
DocumentDbCollection = configData.GetString(prefix + DOCUMENTDB_COLLECTION_KEY),
DocumentDbRUs = configData.GetInt(prefix + DOCUMENTDB_RUS_KEY)
};
}

Просмотреть файл

@ -32,6 +32,46 @@ webservice_url = "${PCS_STORAGEADAPTER_WEBSERVICE_URL}"
webservice_timeout = 10000
[DeviceSimulationService:Storage:Main]
type = "documentDb"
documentdb_connstring = "${PCS_STORAGEADAPTER_DOCUMENTDB_CONNSTRING}"
documentdb_database = "devicesimulation"
documentdb_collection = "main"
documentdb_collection_RUs = 400
[DeviceSimulationService:Storage:Nodes]
type = "documentDb"
documentdb_connstring = "${PCS_STORAGEADAPTER_DOCUMENTDB_CONNSTRING}"
documentdb_database = "devicesimulation"
documentdb_collection = "nodes"
documentdb_collection_RUs = 400
[DeviceSimulationService:Storage:Simulations]
type = "documentDb"
documentdb_connstring = "${PCS_STORAGEADAPTER_DOCUMENTDB_CONNSTRING}"
documentdb_database = "devicesimulation"
documentdb_collection = "simulations"
documentdb_collection_RUs = 400
[DeviceSimulationService:Storage:Devices]
type = "documentDb"
documentdb_connstring = "${PCS_STORAGEADAPTER_DOCUMENTDB_CONNSTRING}"
documentdb_database = "devicesimulation"
documentdb_collection = "devices"
documentdb_collection_RUs = 2500
[DeviceSimulationService:Storage:Partitions]
type = "documentDb"
documentdb_connstring = "${PCS_STORAGEADAPTER_DOCUMENTDB_CONNSTRING}"
documentdb_database = "devicesimulation"
documentdb_collection = "partitions"
documentdb_collection_RUs = 2500
[DeviceSimulationService:Deployment]
# AAD Domain of the Azure subscription where the Azure IoT Hub is deployed.
# The value is optional because the service can be deployed without a hub.

Просмотреть файл

@ -17,6 +17,7 @@ services:
environment:
- PCS_IOTHUB_CONNSTRING
- PCS_STORAGEADAPTER_WEBSERVICE_URL=http://storageadapter:9022/v1
- PCS_STORAGEADAPTER_DOCUMENTDB_CONNSTRING
- PCS_AUTH_REQUIRED
- PCS_CORS_WHITELIST
- PCS_AUTH_ISSUER