From 903a87f9476d6ad7be80e03af1bee62778399675 Mon Sep 17 00:00:00 2001 From: Michael DiLeo Date: Thu, 6 Aug 2026 13:44:58 -0500 Subject: [PATCH] remove the heartbeat history configuration for a window --- dotnet/SafelyYou/Config/HeartBeatHistoryConfig.cs | 6 ------ dotnet/SafelyYou/Devices.cs | 2 ++ dotnet/SafelyYou/Program.cs | 7 ------- dotnet/SafelyYou/appsettings.json | 3 --- 4 files changed, 2 insertions(+), 16 deletions(-) delete mode 100644 dotnet/SafelyYou/Config/HeartBeatHistoryConfig.cs diff --git a/dotnet/SafelyYou/Config/HeartBeatHistoryConfig.cs b/dotnet/SafelyYou/Config/HeartBeatHistoryConfig.cs deleted file mode 100644 index 88fd548..0000000 --- a/dotnet/SafelyYou/Config/HeartBeatHistoryConfig.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace SafelyYou.Config; - -public class HeartBeatHistoryConfig -{ - public TimeSpan Window { get; set; } -} \ No newline at end of file diff --git a/dotnet/SafelyYou/Devices.cs b/dotnet/SafelyYou/Devices.cs index 8fddba7..b784d54 100644 --- a/dotnet/SafelyYou/Devices.cs +++ b/dotnet/SafelyYou/Devices.cs @@ -16,12 +16,14 @@ public sealed class KnownDevices public sealed class DeviceHeartBeatHistory { + public enum AddResult { Added, OutOfSequence } public long NumberOfHeartBeats { get; private set; } public DateTimeOffset? FirstHeartBeat { get; private set; } public DateTimeOffset? LastHeartBeat { get; private set; } + public AddResult Add(DateTimeOffset sentAt) { // Reject heartbeats that arrive before the latest registered time. diff --git a/dotnet/SafelyYou/Program.cs b/dotnet/SafelyYou/Program.cs index 228779f..2a4157b 100644 --- a/dotnet/SafelyYou/Program.cs +++ b/dotnet/SafelyYou/Program.cs @@ -1,6 +1,5 @@ using SafelyYou; using SafelyYou.Api; -using SafelyYou.Config; var builder = WebApplication.CreateBuilder(args); @@ -14,12 +13,6 @@ builder.Services.AddSingleton(_ => return new KnownDevices(deviceIds); }); -builder.Services.AddSingleton(_ => -{ - var millis = builder.Configuration.GetSection("HeartBeatHistory").GetValue("WindowMillis"); - return new HeartBeatHistoryConfig() { Window = TimeSpan.FromMilliseconds(millis) }; -}); - builder.Services.AddSingleton(); builder.Services.AddSingleton(); diff --git a/dotnet/SafelyYou/appsettings.json b/dotnet/SafelyYou/appsettings.json index 6b45987..10f68b8 100644 --- a/dotnet/SafelyYou/appsettings.json +++ b/dotnet/SafelyYou/appsettings.json @@ -1,7 +1,4 @@ { - "HeartBeatHistory" : { - "WindowMillis" : 1000 - }, "Logging": { "LogLevel": { "Default": "Information",