Auto: ablegacy-12 — auto-demote on comm failure

Closes #255
This commit is contained in:
Joseph Doherty
2026-04-26 08:44:53 -04:00
parent 8ee65a75d2
commit 1e3053c0d8
18 changed files with 1160 additions and 31 deletions
@@ -45,7 +45,14 @@ public static class AbLegacyDriverFactoryExtensions
DeviceName: d.DeviceName,
// PR 9 — per-device timeout / retry overrides. Device-level wins over driver-wide.
Timeout: d.TimeoutMs is int devMs ? TimeSpan.FromMilliseconds(devMs) : null,
Retries: d.Retries))]
Retries: d.Retries,
// PR ablegacy-12 / #255 — auto-demote knobs.
Demote: d.Demote is null ? null : new AbLegacyDemoteOptions(
FailureThreshold: d.Demote.FailureThreshold ?? 3,
DemoteFor: d.Demote.DemoteForMs is int demMs
? TimeSpan.FromMilliseconds(demMs)
: null,
Enabled: d.Demote.Enabled ?? true)))]
: [],
Tags = dto.Tags is { Count: > 0 }
? [.. dto.Tags.Select(t => new AbLegacyTagDefinition(
@@ -209,6 +216,26 @@ public static class AbLegacyDriverFactoryExtensions
/// <c>null</c> at both levels = single attempt.
/// </summary>
public int? Retries { get; init; }
/// <summary>
/// PR ablegacy-12 / #255 — optional per-device auto-demote knobs. <c>null</c>
/// means "use the documented defaults" (<c>FailureThreshold=3</c>,
/// <c>DemoteFor=30s</c>, <c>Enabled=true</c>) — the driver still demotes by
/// default. Set <c>Enabled=false</c> in the JSON to opt out entirely.
/// </summary>
public AbLegacyDemoteDto? Demote { get; init; }
}
/// <summary>
/// PR ablegacy-12 / #255 — JSON DTO for the auto-demote knobs. Times are
/// ms-suffixed for consistency with the rest of the driver config (TimeoutMs,
/// IntervalMs).
/// </summary>
internal sealed class AbLegacyDemoteDto
{
public int? FailureThreshold { get; init; }
public int? DemoteForMs { get; init; }
public bool? Enabled { get; init; }
}
internal sealed class AbLegacyTagDto