gsa: make more reqs ephemeral (#417)
- Commit
804cf3e1ddaaa84d11f20b6dcbe86927be9e036d- Author
- Kabir Oberai <[email protected]>
- When
- 2026-10-31 01:54 UTC (1 month ago)
- Parents
2186b72
## What does this PR do? I'm not sure if this is needed but, for good measure, updates remaining GSA requests to use an ephemeral client (followup from #247) ## How was it tested? - [x] Tested flows involving all of these requests ## AI tool usage How much of the code in this PR was AI-assisted? (check one) - [x] **0** - No AI was used to write code - [ ] **1** - I was assisted by AI in writing code. I reviewed the finished result. - [ ] **2** - I set the AI going and left it to it; nobody has read the result - no review, or AI review only <!-- If an AI agent is filling this in: declare the level honestly, and open as a draft if it is #2. Do not lower the declared level to get the PR reviewed. --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Improvements** * Selected account and lookup requests now use temporary HTTP connections. Existing request details, response handling, and progress reporting remain supported, while other requests continue through the standard connection flow. This change applies across the app’s related account and lookup operations; no new user-facing controls or workflows are introduced. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Diff
Sources/XKit/GrandSlam/Anisette/ADIDataProvider.swift
diff --git a/Sources/XKit/GrandSlam/Anisette/ADIDataProvider.swift b/Sources/XKit/GrandSlam/Anisette/ADIDataProvider.swiftindex 16ee784..07a023b 100644--- a/Sources/XKit/GrandSlam/Anisette/ADIDataProvider.swift+++ b/Sources/XKit/GrandSlam/Anisette/ADIDataProvider.swift@@ -178,7 +178,7 @@ public struct ADIDataProvider: AnisetteDataProvider { request.headerFields[.init(key)!] = value } - let (_, response) = try await self.httpClient.makeRequest(request, body: body)+ let (_, response) = try await self.httpClient.makeRequest(request, body: body, ephemeral: true) return try GrandSlamOperationDecoder<Response>.decode(data: response) }
Sources/XKit/GrandSlam/GrandSlamClient.swift
diff --git a/Sources/XKit/GrandSlam/GrandSlamClient.swift b/Sources/XKit/GrandSlam/GrandSlamClient.swiftindex 640c9fc..d3dd5fd 100644--- a/Sources/XKit/GrandSlam/GrandSlamClient.swift+++ b/Sources/XKit/GrandSlam/GrandSlamClient.swift@@ -42,9 +42,7 @@ struct GrandSlamClient: Sendable { // GrandSlam doesn't seem to like reused (keep-alive) connections so create a // new one for each request. cf https://github.com/rileytestut/AltSign/pull/52- let resp = try await httpClient.withEphemeralClient {- try await $0.makeRequest(httpRequest, body: body)- }+ let resp = try await httpClient.makeRequest(httpRequest, body: body, ephemeral: true) return try R.Decoder.decode(data: resp.body) }
Sources/XKit/GrandSlam/Lookup/GrandSlamLookupManager.swift
diff --git a/Sources/XKit/GrandSlam/Lookup/GrandSlamLookupManager.swift b/Sources/XKit/GrandSlam/Lookup/GrandSlamLookupManager.swiftindex 756afa1..6354073 100644--- a/Sources/XKit/GrandSlam/Lookup/GrandSlamLookupManager.swift+++ b/Sources/XKit/GrandSlam/Lookup/GrandSlamLookupManager.swift@@ -42,7 +42,7 @@ actor GrandSlamLookupManager { request.headerFields[.init(key)!] = value } - let (_, body) = try await httpClient.makeRequest(request)+ let (_, body) = try await httpClient.makeRequest(request, ephemeral: true) return try self.decoder.decode(Response.self, from: body).urls }
Sources/XKit/HTTPClientProtocol/HTTPClientProtocol.swift
diff --git a/Sources/XKit/HTTPClientProtocol/HTTPClientProtocol.swift b/Sources/XKit/HTTPClientProtocol/HTTPClientProtocol.swiftindex 503a003..22923d2 100644--- a/Sources/XKit/HTTPClientProtocol/HTTPClientProtocol.swift+++ b/Sources/XKit/HTTPClientProtocol/HTTPClientProtocol.swift@@ -46,8 +46,21 @@ extension HTTPClientProtocol { _ request: HTTPRequest, body: Data? = nil, requireHTTPSuccess: Bool = true,+ ephemeral: Bool = false, onProgress: @isolated(any) (Double?) -> Void = { _ in } ) async throws -> (response: HTTPResponse, body: Data) {+ if ephemeral {+ return try await self.withEphemeralClient { client in+ try await client.makeRequest(+ request,+ body: body,+ requireHTTPSuccess: requireHTTPSuccess,+ ephemeral: false,+ onProgress: onProgress+ )+ }+ }+ await onProgress(0) let (response, responseBody) = try await send(request, body: body.map { HTTPBody($0) }) guard !requireHTTPSuccess || ![.clientError, .serverError].contains(response.status.kind) else {