Skip to content
This repository was archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
Revert PR 296, due to errors seen during the release process (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
dluc authored and hathind-ms committed Nov 22, 2018
1 parent 2680d01 commit c1bc7e9
Show file tree
Hide file tree
Showing 10 changed files with 278 additions and 321 deletions.
12 changes: 0 additions & 12 deletions Services/IStatusService.cs

This file was deleted.

22 changes: 0 additions & 22 deletions Services/Models/StatusResultServiceModel.cs

This file was deleted.

26 changes: 0 additions & 26 deletions Services/Models/StatusServiceModel.cs

This file was deleted.

14 changes: 6 additions & 8 deletions Services/PreprovisionedIotHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.Services
public interface IPreprovisionedIotHub
{
// Ping the registry to see if the connection is healthy
Task<StatusResultServiceModel> PingRegistryAsync();
Task<Tuple<bool, string>> PingRegistryAsync();
}

public class PreprovisionedIotHub : IPreprovisionedIotHub
Expand All @@ -36,23 +36,21 @@ public PreprovisionedIotHub(
}

// Ping the registry to see if the connection is healthy
public async Task<StatusResultServiceModel> PingRegistryAsync()
public async Task<Tuple<bool, string>> PingRegistryAsync()
{
var result = new StatusResultServiceModel(false, "IoTHub check failed");
await this.InitAsync();

try
{
await this.InitAsync();
await this.registry.GetDeviceAsync("healthcheck");
result.IsHealthy = true;
result.Message = "Alive and Well!";
return new Tuple<bool, string>(true, "OK");
}
catch (Exception e)
{
this.log.Error("Device registry test failed", e);
return new Tuple<bool, string>(false, e.Message);
}

return result;
}

// This call can throw an exception, which is fine when the exception happens during a method
Expand Down
197 changes: 0 additions & 197 deletions Services/StatusService.cs

This file was deleted.

32 changes: 31 additions & 1 deletion Services/StorageAdapter/StorageAdapterClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Diagnostics;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Exceptions;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Http;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Models;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Runtime;
using Newtonsoft.Json;

namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.StorageAdapter
{
public interface IStorageAdapterClient
{
Task<Tuple<bool, string>> PingAsync();
Task<ValueListApiModel> GetAllAsync(string collectionId);
Task<ValueApiModel> GetAsync(string collectionId, string key);
Task<ValueApiModel> CreateAsync(string collectionId, string value);
Expand Down Expand Up @@ -50,6 +50,36 @@ public StorageAdapterClient(
this.diagnosticsLogger = diagnosticsLogger;
}

public async Task<Tuple<bool, string>> PingAsync()
{
var status = false;
var message = "";

try
{
var response = await this.httpClient.GetAsync(this.PrepareRequest($"status"));
if (response.IsError)
{
message = "Status code: " + response.StatusCode;
}
else
{
var data = JsonConvert.DeserializeObject<Dictionary<string, object>>(response.Content);
message = data["Status"].ToString();
status = data["Status"].ToString().StartsWith("OK:");
}
}
catch (Exception e)
{
var msg = "Storage adapter check failed";
this.log.Error(msg, e);
this.diagnosticsLogger.LogServiceError(msg, e.Message);
message = e.Message;
}

return new Tuple<bool, string>(status, message);
}

public async Task<ValueListApiModel> GetAllAsync(string collectionId)
{
var response = await this.httpClient.GetAsync(
Expand Down
Loading

0 comments on commit c1bc7e9

Please sign in to comment.