fix(gateway): split the heartbeat check interval from the send interval; expose the two fixed worker-client timeouts (mxaccessgw#192)
R21-O14: MxGateway:Worker:HeartbeatIntervalSeconds was documented as the worker heartbeat send interval, but it never reached the worker (which sends on its own fixed 5 s) and only set the gateway's HeartbeatCheckInterval. It is renamed HeartbeatCheckIntervalSeconds (default 5, unchanged). The old key stays as a deprecated alias with the same meaning so existing appsettings keep working; setting both is a validation error. The grace-vs-interval check now compares against the resolved check interval. R21-O15: WorkerClientOptions.EventChannelFullModeTimeout and HeartbeatStuckCeiling were always their compile-time defaults. They are now MxGateway:Worker:EventChannelFullModeTimeoutMilliseconds (default 5000, > 0) and HeartbeatStuckCeilingSeconds (default 75, >= HeartbeatGraceSeconds). The factory's mapping moved into SessionWorkerClientFactory.CreateWorkerClientOptions so every field is set from configuration and is testable. The effective-config record shows the resolved check interval and both new values. Docs: GatewayConfiguration.md, GatewayProcessDesign.md sample, MxAccessWorkerInstanceDesign.md heartbeat section; appsettings.json uses the new keys. Tests: CreateWorkerClientOptions mapping + defaults (fail under a mutated mapping), alias honoured, both-keys conflict, and bounds for the new options. Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
@@ -258,19 +258,37 @@ public sealed class GatewayOptionsValidator : OptionsValidatorBase<GatewayOption
|
||||
options.ShutdownTimeoutSeconds,
|
||||
"MxGateway:Worker:ShutdownTimeoutSeconds must be greater than zero.",
|
||||
builder);
|
||||
if (options.HeartbeatCheckIntervalSeconds is not null && options.HeartbeatIntervalSeconds is not null)
|
||||
{
|
||||
builder.Add(
|
||||
"MxGateway:Worker:HeartbeatIntervalSeconds is a deprecated alias of HeartbeatCheckIntervalSeconds; set only HeartbeatCheckIntervalSeconds.");
|
||||
}
|
||||
|
||||
int heartbeatCheckIntervalSeconds = options.ResolveHeartbeatCheckIntervalSeconds();
|
||||
AddIfNotPositive(
|
||||
options.HeartbeatIntervalSeconds,
|
||||
"MxGateway:Worker:HeartbeatIntervalSeconds must be greater than zero.",
|
||||
heartbeatCheckIntervalSeconds,
|
||||
"MxGateway:Worker:HeartbeatCheckIntervalSeconds must be greater than zero.",
|
||||
builder);
|
||||
AddIfNotPositive(
|
||||
options.HeartbeatGraceSeconds,
|
||||
"MxGateway:Worker:HeartbeatGraceSeconds must be greater than zero.",
|
||||
builder);
|
||||
|
||||
if (options.HeartbeatGraceSeconds < options.HeartbeatIntervalSeconds)
|
||||
if (options.HeartbeatGraceSeconds < heartbeatCheckIntervalSeconds)
|
||||
{
|
||||
builder.Add(
|
||||
"MxGateway:Worker:HeartbeatGraceSeconds must be greater than or equal to HeartbeatIntervalSeconds.");
|
||||
"MxGateway:Worker:HeartbeatGraceSeconds must be greater than or equal to HeartbeatCheckIntervalSeconds.");
|
||||
}
|
||||
|
||||
AddIfNotPositive(
|
||||
options.EventChannelFullModeTimeoutMilliseconds,
|
||||
"MxGateway:Worker:EventChannelFullModeTimeoutMilliseconds must be greater than zero.",
|
||||
builder);
|
||||
|
||||
if (options.HeartbeatStuckCeilingSeconds < options.HeartbeatGraceSeconds)
|
||||
{
|
||||
builder.Add(
|
||||
"MxGateway:Worker:HeartbeatStuckCeilingSeconds must be greater than or equal to HeartbeatGraceSeconds.");
|
||||
}
|
||||
|
||||
if (options.EventQueueCapacity is < MinimumWorkerEventQueueCapacity or > MaximumWorkerEventQueueCapacity)
|
||||
|
||||
Reference in New Issue
Block a user