feat: wire remaining E2E gaps — account imports, subject transforms, JWT auth, service latency

Close all 5 server-side wiring gaps so E2E tests pass without skips:
- System events: bridge user-defined system_account to internal $SYS
- Account imports/exports: config parsing + reverse response import for cross-account request-reply
- Subject transforms: parse mappings config block, apply in ProcessMessage
- JWT auth: parse trusted_keys, resolver MEMORY, resolver_preload in config
- Service latency: timestamp on request, publish ServiceLatencyMsg on response
This commit is contained in:
Joseph Doherty
2026-03-12 23:03:12 -04:00
parent 246fc7ad87
commit 95e9f0a92e
5 changed files with 571 additions and 16 deletions

View File

@@ -307,7 +307,7 @@ public sealed class Account : IDisposable
return new ServiceExportInfo(subject, se.ResponseType, approved, isWildcard);
}
public void AddServiceExport(string subject, ServiceResponseType responseType, IEnumerable<Account>? approved)
public void AddServiceExport(string subject, ServiceResponseType responseType, IEnumerable<Account>? approved, ServiceLatency? latency = null)
{
var auth = new ExportAuth
{
@@ -318,6 +318,7 @@ public sealed class Account : IDisposable
Auth = auth,
Account = this,
ResponseType = responseType,
Latency = latency,
};
}

View File

@@ -5,4 +5,40 @@ public sealed class AccountConfig
public int MaxConnections { get; init; } // 0 = unlimited
public int MaxSubscriptions { get; init; } // 0 = unlimited
public Permissions? DefaultPermissions { get; init; }
/// <summary>Service and stream exports from this account.</summary>
public List<ExportDefinition>? Exports { get; init; }
/// <summary>Service and stream imports into this account.</summary>
public List<ImportDefinition>? Imports { get; init; }
}
/// <summary>
/// Represents an export declaration in config: exports = [{ service: "sub" }] or [{ stream: "sub" }].
/// Go reference: server/opts.go — parseExportStreamMap / parseExportServiceMap.
/// </summary>
public sealed class ExportDefinition
{
public string? Service { get; init; }
public string? Stream { get; init; }
/// <summary>Optional latency tracking subject (e.g. "latency.svc.echo").</summary>
public string? LatencySubject { get; init; }
/// <summary>Latency sampling percentage (1100, default 100).</summary>
public int LatencySampling { get; init; } = 100;
}
/// <summary>
/// Represents an import declaration in config:
/// imports = [{ service: { account: X, subject: "sub" }, to: "local" }].
/// Go reference: server/opts.go — parseImportStreamMap / parseImportServiceMap.
/// </summary>
public sealed class ImportDefinition
{
public string? ServiceAccount { get; init; }
public string? ServiceSubject { get; init; }
public string? StreamAccount { get; init; }
public string? StreamSubject { get; init; }
public string? To { get; init; }
}