Fix: NucuCar.Sensors creating a telemetry singleton when telemetry is disabled

This commit is contained in:
Denis-Cosmin Nutiu 2019-11-24 14:16:35 +02:00
parent 8434d4f519
commit d703b53a6b

View file

@ -18,7 +18,10 @@ namespace NucuCar.Sensors.Telemetry
_serviceEnabled = configuration.GetValue<bool>("Telemetry:Enabled"); _serviceEnabled = configuration.GetValue<bool>("Telemetry:Enabled");
_interval = configuration.GetValue<int>("Telemetry:Interval"); _interval = configuration.GetValue<int>("Telemetry:Interval");
var azureIotHubConnectionString = configuration.GetValue<string>("Telemetry:AzureIotHubConnectionString"); var azureIotHubConnectionString = configuration.GetValue<string>("Telemetry:AzureIotHubConnectionString");
SensorTelemetryPublisher.CreateSingleton(azureIotHubConnectionString, "NucuCar.Sensors", logger); if (_serviceEnabled)
{
SensorTelemetryPublisher.CreateSingleton(azureIotHubConnectionString, "NucuCar.Sensors", logger);
}
} }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) protected override async Task ExecuteAsync(CancellationToken stoppingToken)