feat(scripts): realign Test Run with runtime API, add anonymous-object calls and instance binding
The Test Run sandbox and Monaco analysis modelled a script API that had drifted from the site runtime's ScriptGlobals, so real scripts failed to compile in Test Run. Realign both to the runtime surface (Instance/Scripts/ExternalSystem/Attributes/Children/Parent) and drop the duplicate ScriptHost stub so the two cannot diverge again. - Script calls (Scripts.CallShared, Instance.CallScript, Route.To().Call) accept an anonymous object instead of a hand-built dictionary, via a shared ScriptArgs normalizer; existing dictionary calls still compile. - Test Run can optionally bind to a deployed instance, so Instance/ Attributes/CallScript route to it cross-site; adds site-side RouteToGetAttributes/RouteToSetAttributes handlers. - Adds Test Run panels to the API method and template script editors. - Fixes the TestDatabaseQuery seed script, which queried a table that never existed. Also commits unrelated in-progress work already in the tree: the health monitoring report loop, site streaming changes, and the Admin/Design data-connection and SMTP page reorganization.
This commit is contained in:
@@ -47,6 +47,7 @@ public class CentralHealthAggregator : BackgroundService, ICentralHealthAggregat
|
||||
SiteId = report.SiteId,
|
||||
LatestReport = report,
|
||||
LastReportReceivedAt = now,
|
||||
LastHeartbeatAt = now,
|
||||
LastSequenceNumber = report.SequenceNumber,
|
||||
IsOnline = true
|
||||
};
|
||||
@@ -64,6 +65,7 @@ public class CentralHealthAggregator : BackgroundService, ICentralHealthAggregat
|
||||
var wasOffline = !existing.IsOnline;
|
||||
existing.LatestReport = report;
|
||||
existing.LastReportReceivedAt = now;
|
||||
existing.LastHeartbeatAt = now;
|
||||
existing.LastSequenceNumber = report.SequenceNumber;
|
||||
existing.IsOnline = true;
|
||||
|
||||
@@ -86,8 +88,8 @@ public class CentralHealthAggregator : BackgroundService, ICentralHealthAggregat
|
||||
if (!_siteStates.TryGetValue(siteId, out var state))
|
||||
return;
|
||||
|
||||
if (receivedAt > state.LastReportReceivedAt)
|
||||
state.LastReportReceivedAt = receivedAt;
|
||||
if (receivedAt > state.LastHeartbeatAt)
|
||||
state.LastHeartbeatAt = receivedAt;
|
||||
|
||||
if (!state.IsOnline)
|
||||
{
|
||||
@@ -141,12 +143,15 @@ public class CentralHealthAggregator : BackgroundService, ICentralHealthAggregat
|
||||
var state = kvp.Value;
|
||||
if (!state.IsOnline) continue;
|
||||
|
||||
var elapsed = now - state.LastReportReceivedAt;
|
||||
// Use LastHeartbeatAt — heartbeats arrive every ~5s from any
|
||||
// healthy site node, so OfflineTimeout only fires when no node
|
||||
// can reach central, not during single-node failovers.
|
||||
var elapsed = now - state.LastHeartbeatAt;
|
||||
if (elapsed > _options.OfflineTimeout)
|
||||
{
|
||||
state.IsOnline = false;
|
||||
_logger.LogWarning(
|
||||
"Site {SiteId} marked offline — no report for {Elapsed}s (timeout: {Timeout}s)",
|
||||
"Site {SiteId} marked offline — no signal for {Elapsed}s (timeout: {Timeout}s)",
|
||||
state.SiteId, elapsed.TotalSeconds, _options.OfflineTimeout.TotalSeconds);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user