Skip to content

Commit

Permalink
Address coderabbit feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Thaler <[email protected]>
  • Loading branch information
dthaler committed Oct 30, 2024
1 parent c9509d8 commit 591b026
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions OrcanodeMonitor/Core/Fetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public async static Task<string> GetDataplicityDataAsync(string serial, ILogger
})
{
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Token", orcasound_dataplicity_token);
HttpResponseMessage response = await _httpClient.SendAsync(request);
using HttpResponseMessage response = await _httpClient.SendAsync(request);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}
Expand Down Expand Up @@ -743,7 +743,7 @@ public static long DateTimeToUnixTimeStamp(DateTime dateTime)
public async static Task UpdateS3DataAsync(OrcanodeMonitorContext context, Orcanode node, ILogger logger)
{
string url = "https://" + node.S3Bucket + ".s3.amazonaws.com/" + node.S3NodeName + "/latest.txt";
HttpResponseMessage response = await _httpClient.GetAsync(url);
using HttpResponseMessage response = await _httpClient.GetAsync(url);
if (response.StatusCode == HttpStatusCode.NotFound)
{
// Absent.
Expand Down Expand Up @@ -791,6 +791,14 @@ public static List<OrcanodeEvent> GetEvents(OrcanodeMonitorContext context, int
return orcanodeEvents;
}

/// <summary>
/// Get recent events for a node
/// </summary>
/// <param name="context"></param>
/// <param name="id">ID of node to get events for</param>
/// <param name="since">Time to get events since</param>
/// <param name="logger"></param>
/// <returns>null on error, or list of events on success</returns>
public static List<OrcanodeEvent>? GetRecentEventsForNode(OrcanodeMonitorContext context, string id, DateTime since, ILogger logger)
{
try
Expand Down Expand Up @@ -853,7 +861,7 @@ public async static Task UpdateManifestTimestampAsync(OrcanodeMonitorContext con
OrcanodeOnlineStatus oldStatus = node.S3StreamStatus;

string url = "https://" + node.S3Bucket + ".s3.amazonaws.com/" + node.S3NodeName + "/hls/" + unixTimestampString + "/live.m3u8";
HttpResponseMessage response = await _httpClient.GetAsync(url);
using HttpResponseMessage response = await _httpClient.GetAsync(url);
if (!response.IsSuccessStatusCode)
{
return;
Expand Down Expand Up @@ -890,7 +898,7 @@ public async static Task UpdateManifestTimestampAsync(OrcanodeMonitorContext con
{
// We couldn't fetch the stream audio so could not update the
// audio standard deviation. Just ignore this for now.
logger.LogError(ex, "Exception in UpdateS3DataAsync");
logger.LogError(ex, "Exception in UpdateManifestTimestampAsync");
}

OrcanodeOnlineStatus newStatus = node.S3StreamStatus;
Expand Down
2 changes: 1 addition & 1 deletion OrcanodeMonitor/Core/MezmoFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public async static Task<string> GetMezmoDataAsync(string url)
})
{
request.Headers.Add("servicekey", service_key);
HttpResponseMessage response = await _httpClient.SendAsync(request);
using HttpResponseMessage response = await _httpClient.SendAsync(request);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}
Expand Down

0 comments on commit 591b026

Please sign in to comment.