Skip to content

Commit 14f5e0a

Browse files
committed
Move away from deprecated methods
1 parent 2f46bf1 commit 14f5e0a

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

Sources/PackageMetadata/PackageMetadata.swift

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -329,37 +329,32 @@ public struct PackageSearchClient {
329329
timeout: DispatchTimeInterval? = .none,
330330
observabilityScope: ObservabilityScope,
331331
callbackQueue: DispatchQueue,
332-
completion: @escaping (Result<Set<PackageIdentity>, Error>) -> Void
332+
completion: @Sendable @escaping (Result<Set<PackageIdentity>, Error>) -> Void
333333
) {
334-
registryClient.lookupIdentities(
335-
scmURL: scmURL,
336-
timeout: timeout,
337-
observabilityScope: observabilityScope,
338-
callbackQueue: callbackQueue,
339-
completion: completion
340-
)
334+
callbackQueue.asyncResult(completion) {
335+
try await registryClient.lookupIdentities(
336+
scmURL: scmURL,
337+
timeout: timeout,
338+
observabilityScope: observabilityScope
339+
)
340+
}
341341
}
342342

343343
public func lookupSCMURLs(
344344
package: PackageIdentity,
345345
timeout: DispatchTimeInterval? = .none,
346346
observabilityScope: ObservabilityScope,
347347
callbackQueue: DispatchQueue,
348-
completion: @escaping (Result<Set<SourceControlURL>, Error>) -> Void
348+
completion: @Sendable @escaping (Result<Set<SourceControlURL>, Error>) -> Void
349349
) {
350-
registryClient.getPackageMetadata(
351-
package: package,
352-
timeout: timeout,
353-
observabilityScope: observabilityScope,
354-
callbackQueue: callbackQueue
355-
) { result in
356-
do {
357-
let metadata = try result.get()
358-
let alternateLocations = metadata.alternateLocations
359-
return completion(.success(Set(alternateLocations)))
360-
} catch {
361-
return completion(.failure(error))
362-
}
350+
callbackQueue.asyncResult(completion) {
351+
let metadata = try await registryClient.getPackageMetadata(
352+
package: package,
353+
timeout: timeout,
354+
observabilityScope: observabilityScope
355+
)
356+
let alternateLocations = metadata.alternateLocations
357+
return Set(alternateLocations)
363358
}
364359
}
365360
}

0 commit comments

Comments
 (0)