Skip to content

Reduce usage of callback and dispatch methods in favor of async/await #8744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Sources/Build/BuildOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
pluginName: plugin.moduleName,
toolsVersion: plugin.toolsVersion,
observabilityScope: self.observabilityScope,
callbackQueue: DispatchQueue.sharedConcurrent,
delegate: delegate
)

Expand Down
1 change: 0 additions & 1 deletion Sources/Commands/PackageCommands/PluginCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ struct PluginCommand: AsyncSwiftCommand {
fileSystem: swiftCommandState.fileSystem,
modulesGraph: packageGraph,
observabilityScope: swiftCommandState.observabilityScope,
callbackQueue: delegateQueue,
delegate: pluginDelegate
)

Expand Down
23 changes: 0 additions & 23 deletions Sources/PackageRegistry/ChecksumTOFU.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,6 @@ struct PackageVersionChecksumTOFU {
}
}

@available(*, noasync, message: "Use the async alternative")
func validateSourceArchive(
registry: Registry,
package: PackageIdentity.RegistryIdentity,
version: Version,
checksum: String,
timeout: DispatchTimeInterval?,
observabilityScope: ObservabilityScope,
callbackQueue: DispatchQueue,
completion: @escaping @Sendable (Result<Void, Error>) -> Void
) {
callbackQueue.asyncResult(completion) {
try await self.validateSourceArchive(
registry: registry,
package: package,
version: version,
checksum: checksum,
timeout: timeout,
observabilityScope: observabilityScope
)
}
}

private func getExpectedChecksum(
registry: Registry,
package: PackageIdentity.RegistryIdentity,
Expand Down
19 changes: 0 additions & 19 deletions Sources/PackageRegistry/RegistryClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -613,25 +613,6 @@ public final class RegistryClient: AsyncCancellable {
}
}

@available(*, deprecated, message: "Use the async alternative")
public func getAvailableManifests(
package: PackageIdentity,
version: Version,
timeout: DispatchTimeInterval? = .none,
observabilityScope: ObservabilityScope,
callbackQueue: DispatchQueue,
completion: @escaping @Sendable (Result<[String: (toolsVersion: ToolsVersion, content: String?)], Error>) -> Void
) {
callbackQueue.asyncResult(completion) {
try await self.getAvailableManifests(
package: package,
version: version,
timeout: timeout,
observabilityScope: observabilityScope
)
}
}

public func getManifestContent(
package: PackageIdentity,
version: Version,
Expand Down
17 changes: 0 additions & 17 deletions Sources/PackageRegistry/RegistryDownloadsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,6 @@ public class RegistryDownloadsManager: AsyncCancellable {
return try await task.value
}

@available(*, noasync, message: "Use the async alternative")
public func lookup(
package: PackageIdentity,
version: Version,
observabilityScope: ObservabilityScope,
callbackQueue: DispatchQueue,
completion: @escaping @Sendable (Result<Basics.AbsolutePath, Error>) -> Void
) {
callbackQueue.asyncResult(completion) {
try await self.lookup(
package: package,
version: version,
observabilityScope: observabilityScope
)
}
}

/// Cancel any outstanding requests
public func cancel(deadline: DispatchTime) async throws {
try await self.registryClient.cancel(deadline: deadline)
Expand Down
57 changes: 0 additions & 57 deletions Sources/PackageRegistry/SignatureValidation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,33 +94,6 @@ struct SignatureValidation {
return signingEntity;
}

@available(*, noasync, message: "Use the async alternative")
func validate(
registry: Registry,
package: PackageIdentity.RegistryIdentity,
version: Version,
content: Data,
configuration: RegistryConfiguration.Security.Signing,
timeout: DispatchTimeInterval?,
fileSystem: FileSystem,
observabilityScope: ObservabilityScope,
callbackQueue: DispatchQueue,
completion: @escaping @Sendable (Result<SigningEntity?, Error>) -> Void
) {
callbackQueue.asyncResult(completion) {
try await self.validate(
registry: registry,
package: package,
version: version,
content: content,
configuration: configuration,
timeout: timeout,
fileSystem: fileSystem,
observabilityScope: observabilityScope
)
}
}

private func getAndValidateSourceArchiveSignature(
registry: Registry,
package: PackageIdentity.RegistryIdentity,
Expand Down Expand Up @@ -350,36 +323,6 @@ struct SignatureValidation {
return signingEntity;
}


@available(*, noasync, message: "Use the async alternative")
func validate(
registry: Registry,
package: PackageIdentity.RegistryIdentity,
version: Version,
toolsVersion: ToolsVersion?,
manifestContent: String,
configuration: RegistryConfiguration.Security.Signing,
timeout: DispatchTimeInterval?,
fileSystem: FileSystem,
observabilityScope: ObservabilityScope,
callbackQueue: DispatchQueue,
completion: @escaping @Sendable (Result<SigningEntity?, Error>) -> Void
) {
callbackQueue.asyncResult(completion) {
try await self.validate(
registry: registry,
package: package,
version: version,
toolsVersion: toolsVersion,
manifestContent: manifestContent,
configuration: configuration,
timeout: timeout,
fileSystem: fileSystem,
observabilityScope: observabilityScope
)
}
}

private func getAndValidateManifestSignature(
registry: Registry,
package: PackageIdentity.RegistryIdentity,
Expand Down
20 changes: 0 additions & 20 deletions Sources/PackageRegistry/SigningEntityTOFU.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,26 +76,6 @@ struct PackageSigningEntityTOFU {
)
}

@available(*, noasync, message: "Use the async alternative")
func validate(
registry: Registry,
package: PackageIdentity.RegistryIdentity,
version: Version,
signingEntity: SigningEntity?,
observabilityScope: ObservabilityScope,
completion: @escaping @Sendable (Result<Void, Error>) -> Void
) {
DispatchQueue.sharedConcurrent.asyncResult(completion) {
try await self.validate(
registry: registry,
package: package,
version: version,
signingEntity: signingEntity,
observabilityScope: observabilityScope
)
}
}

private func validateSigningEntity(
registry: Registry,
package: PackageIdentity.RegistryIdentity,
Expand Down
Loading