web: show how long a line has been out of contact
The Backend now keeps the time since a link's control layer was last up, because retries move the control state in and out of backoff and its own timestamp keeps resetting. The overview exposes it as control_down_since and the card shows it next to the lost-contact notice.
This commit is contained in:
1 parent
5245f03a78
commit
57acecdb86
7 files changed
+41
-8
No files matched your search
@@ -3,7 +3,8 @@ using MoShiro.Protocol;
|
||||
|
||||
namespace MoShiro.Backend.Application;
|
||||
|
||||
public sealed record ReportedLink(LinkHealth Health, long AtMs);
|
||||
/// <summary><paramref name="DownSinceMs"/>:控制层从什么时候起一直不是在线(Unix 毫秒);在线时为空。重试会让控制层状态反复进出退避,所以由 Backend 连着记,不用状态自己的时间。</summary>
|
||||
public sealed record ReportedLink(LinkHealth Health, long AtMs, long? DownSinceMs = null);
|
||||
|
||||
/// <summary>Latest per-line control and task health reported by dialing nodes. Volatile runtime state, not historical metrics.</summary>
|
||||
public sealed class LinkRuntime
|
||||
@@ -20,7 +21,8 @@ public sealed class LinkRuntime
|
||||
{
|
||||
var key = (dialerId, link.ListenerId, link.IpVersion);
|
||||
current.Add(key);
|
||||
_links[key] = new ReportedLink(link, atMs);
|
||||
long? downSince = link.Control.State == ControlState.Up ? null : _links.TryGetValue(key, out ReportedLink? previous) && previous.DownSinceMs is { } since ? since : atMs;
|
||||
_links[key] = new ReportedLink(link, atMs, downSince);
|
||||
}
|
||||
|
||||
foreach ((string Dialer, string Listener, string IpVersion) key in _links.Keys.Where(k => k.Dialer == dialerId && !current.Contains(k)))
|
||||
@@ -41,7 +43,7 @@ public sealed class LinkRuntime
|
||||
old.Control.RetryInMs = null;
|
||||
old.Task.Quic.State = QuicState.Idle;
|
||||
old.Task.Quic.RetryInMs = null;
|
||||
_links[pair.Key] = new ReportedLink(old, atMs);
|
||||
_links[pair.Key] = new ReportedLink(old, atMs, pair.Value.DownSinceMs ?? atMs);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user