Improve XML documentation coverage across src modules and sync generated analysis artifacts.

This commit is contained in:
Joseph Doherty
2026-03-14 03:56:58 -04:00
parent ba0d65317a
commit 46ead5ea9f
152 changed files with 2821 additions and 11284 deletions

View File

@@ -45,6 +45,8 @@ public static class GatewayCommands
/// Wire format: GS+ {account} {subject}\r\n
/// Go reference: gateway.go — sendGatewaySubsToGateway, RS+ propagation.
/// </summary>
/// <param name="account">Origin account used for gateway interest tracking.</param>
/// <param name="subject">Subject pattern being subscribed across clusters.</param>
public static byte[] FormatSub(string account, string subject)
=> Encoding.UTF8.GetBytes($"GS+ {account} {subject}\r\n");
@@ -53,6 +55,8 @@ public static class GatewayCommands
/// Wire format: GS- {account} {subject}\r\n
/// Go reference: gateway.go — sendGatewayUnsubToGateway, RS- propagation.
/// </summary>
/// <param name="account">Origin account used for gateway interest tracking.</param>
/// <param name="subject">Subject pattern being removed from remote interest state.</param>
public static byte[] FormatUnsub(string account, string subject)
=> Encoding.UTF8.GetBytes($"GS- {account} {subject}\r\n");
@@ -62,6 +66,8 @@ public static class GatewayCommands
/// Mode: "O" for Optimistic (send everything), "I" for Interest-only.
/// Go reference: gateway.go — switchAccountToInterestMode, GMODE command.
/// </summary>
/// <param name="account">Account whose cross-cluster routing mode is being updated.</param>
/// <param name="mode">Target gateway interest mode for that account.</param>
public static byte[] FormatMode(string account, GatewayInterestMode mode)
{
var modeStr = mode == GatewayInterestMode.InterestOnly ? "I" : "O";
@@ -73,6 +79,7 @@ public static class GatewayCommands
/// Returns null if the command prefix is unrecognized.
/// Go reference: gateway.go — processGatewayMsg command dispatch.
/// </summary>
/// <param name="line">Raw protocol line prefix read from a gateway connection.</param>
public static GatewayCommandType? ParseCommandType(ReadOnlySpan<byte> line)
{
if (line.StartsWith(InfoPrefix)) return GatewayCommandType.Info;

View File

@@ -42,6 +42,10 @@ public sealed class GatewayInterestTracker
// Per-account state: mode + no-interest set (Optimistic) or positive interest set (InterestOnly)
private readonly ConcurrentDictionary<string, AccountState> _accounts = new(StringComparer.Ordinal);
/// <summary>
/// Creates a gateway interest tracker with a configurable mode-switch threshold.
/// </summary>
/// <param name="noInterestThreshold">No-interest entry count that triggers InterestOnly mode.</param>
public GatewayInterestTracker(int noInterestThreshold = DefaultNoInterestThreshold)
{
_noInterestThreshold = noInterestThreshold;
@@ -51,6 +55,7 @@ public sealed class GatewayInterestTracker
/// Returns the current interest mode for the given account.
/// Accounts default to Optimistic until the no-interest threshold is exceeded.
/// </summary>
/// <param name="account">Account name/identifier.</param>
public GatewayInterestMode GetMode(string account)
=> _accounts.TryGetValue(account, out var state) ? state.Mode : GatewayInterestMode.Optimistic;
@@ -58,6 +63,8 @@ public sealed class GatewayInterestTracker
/// Track a positive interest (RS+ received from remote) for an account/subject.
/// Go: gateway.go:1540 (processGatewayAccountSub — adds to interest set)
/// </summary>
/// <param name="account">Account name/identifier.</param>
/// <param name="subject">Subject or pattern with positive remote interest.</param>
public void TrackInterest(string account, string subject)
{
var state = GetOrCreateState(account);
@@ -83,6 +90,8 @@ public sealed class GatewayInterestTracker
/// When the no-interest set crosses the threshold, switches to InterestOnly mode.
/// Go: gateway.go:1560 (processGatewayAccountUnsub — tracks no-interest, triggers switch)
/// </summary>
/// <param name="account">Account name/identifier.</param>
/// <param name="subject">Subject or pattern that should be treated as no-interest.</param>
public void TrackNoInterest(string account, string subject)
{
var state = GetOrCreateState(account);
@@ -110,6 +119,8 @@ public sealed class GatewayInterestTracker
/// for the given account and subject.
/// Go: gateway.go:2900 (shouldForwardMsg — checks mode and interest)
/// </summary>
/// <param name="account">Account name/identifier.</param>
/// <param name="subject">Subject being considered for forwarding.</param>
public bool ShouldForward(string account, string subject)
{
if (!_accounts.TryGetValue(account, out var state))
@@ -141,6 +152,7 @@ public sealed class GatewayInterestTracker
/// Called when the remote signals it is in interest-only mode.
/// Go: gateway.go:1500 (switchToInterestOnlyMode)
/// </summary>
/// <param name="account">Account name/identifier.</param>
public void SwitchToInterestOnly(string account)
{
var state = GetOrCreateState(account);
@@ -179,6 +191,7 @@ public sealed class GatewayInterestTracker
/// <summary>Per-account mutable state. All access must be under the instance lock.</summary>
private sealed class AccountState
{
/// <summary>Current forwarding mode for this account.</summary>
public GatewayInterestMode Mode { get; set; } = GatewayInterestMode.Optimistic;
/// <summary>Subjects with no remote interest (used in Optimistic mode).</summary>