fix(external-system-gateway): resolve ExternalSystemGateway-011 — name-keyed repository lookups replace fetch-all-then-filter on the call hot path

This commit is contained in:
Joseph Doherty
2026-05-17 00:02:45 -04:00
parent 1e2e7d2e7c
commit a55502254e
10 changed files with 448 additions and 131 deletions

View File

@@ -6,6 +6,15 @@ public interface IExternalSystemRepository
{
// ExternalSystemDefinition
Task<ExternalSystemDefinition?> GetExternalSystemByIdAsync(int id, CancellationToken cancellationToken = default);
/// <summary>
/// Returns the external system with the given name, or <c>null</c> if no such
/// system exists. A name-keyed lookup so hot-path resolution (e.g. a script's
/// <c>ExternalSystem.Call()</c>) does not have to fetch every system and filter
/// in memory on each call (ExternalSystemGateway-011).
/// </summary>
Task<ExternalSystemDefinition?> GetExternalSystemByNameAsync(string name, CancellationToken cancellationToken = default);
Task<IReadOnlyList<ExternalSystemDefinition>> GetAllExternalSystemsAsync(CancellationToken cancellationToken = default);
Task AddExternalSystemAsync(ExternalSystemDefinition definition, CancellationToken cancellationToken = default);
Task UpdateExternalSystemAsync(ExternalSystemDefinition definition, CancellationToken cancellationToken = default);
@@ -13,6 +22,15 @@ public interface IExternalSystemRepository
// ExternalSystemMethod
Task<ExternalSystemMethod?> GetExternalSystemMethodByIdAsync(int id, CancellationToken cancellationToken = default);
/// <summary>
/// Returns the method with the given name belonging to the given external system,
/// or <c>null</c> if no such method exists. A name-keyed lookup so hot-path
/// resolution does not have to fetch every method of the system and filter in
/// memory on each call (ExternalSystemGateway-011).
/// </summary>
Task<ExternalSystemMethod?> GetMethodByNameAsync(int externalSystemId, string methodName, CancellationToken cancellationToken = default);
Task<IReadOnlyList<ExternalSystemMethod>> GetMethodsByExternalSystemIdAsync(int externalSystemId, CancellationToken cancellationToken = default);
Task AddExternalSystemMethodAsync(ExternalSystemMethod method, CancellationToken cancellationToken = default);
Task UpdateExternalSystemMethodAsync(ExternalSystemMethod method, CancellationToken cancellationToken = default);
@@ -20,6 +38,16 @@ public interface IExternalSystemRepository
// DatabaseConnectionDefinition
Task<DatabaseConnectionDefinition?> GetDatabaseConnectionByIdAsync(int id, CancellationToken cancellationToken = default);
/// <summary>
/// Returns the database connection definition with the given name, or <c>null</c>
/// if no such connection exists. A name-keyed lookup so hot-path resolution (e.g.
/// a script's <c>Database.Connection()</c> / <c>Database.CachedWrite()</c>) does
/// not have to fetch every connection and filter in memory on each call
/// (ExternalSystemGateway-011).
/// </summary>
Task<DatabaseConnectionDefinition?> GetDatabaseConnectionByNameAsync(string name, CancellationToken cancellationToken = default);
Task<IReadOnlyList<DatabaseConnectionDefinition>> GetAllDatabaseConnectionsAsync(CancellationToken cancellationToken = default);
Task AddDatabaseConnectionAsync(DatabaseConnectionDefinition definition, CancellationToken cancellationToken = default);
Task UpdateDatabaseConnectionAsync(DatabaseConnectionDefinition definition, CancellationToken cancellationToken = default);