From 5dba2801af1ad1dd16318deda760ba5bf7ed6943 Mon Sep 17 00:00:00 2001 From: George Barnett Date: Tue, 27 May 2025 09:57:40 +0100 Subject: [PATCH 1/4] Add deprecation warnings Motivation: v2 has moved to a new repo, grpc-swift-2. That's not all that discoverable. Modifications: - Deprecate commonly used high-level types with a link to a forums post explaining the move. Result: Users are notified about the move --- Sources/GRPCCore/Call/Server/RegistrableRPCService.swift | 1 + Sources/GRPCCore/GRPCClient.swift | 3 +++ Sources/GRPCCore/GRPCServer.swift | 3 +++ Sources/GRPCCore/Metadata.swift | 1 + Sources/GRPCCore/Transport/ClientTransport.swift | 1 + Sources/GRPCCore/Transport/ServerTransport.swift | 1 + Sources/GRPCInProcessTransport/InProcessTransport.swift | 1 + 7 files changed, 11 insertions(+) diff --git a/Sources/GRPCCore/Call/Server/RegistrableRPCService.swift b/Sources/GRPCCore/Call/Server/RegistrableRPCService.swift index 7bd5819be..7eed9c647 100644 --- a/Sources/GRPCCore/Call/Server/RegistrableRPCService.swift +++ b/Sources/GRPCCore/Call/Server/RegistrableRPCService.swift @@ -23,6 +23,7 @@ /// ``RPCRouter/registerHandler(forMethod:deserializer:serializer:handler:)`` for each method /// you want to register with the router. @available(gRPCSwift 2.0, *) +@available(*, deprecated, message: "See https://forums.swift.org/t/80177") public protocol RegistrableRPCService: Sendable { /// Registers methods to server with the provided ``RPCRouter``. /// diff --git a/Sources/GRPCCore/GRPCClient.swift b/Sources/GRPCCore/GRPCClient.swift index a41c8b261..97e540ae5 100644 --- a/Sources/GRPCCore/GRPCClient.swift +++ b/Sources/GRPCCore/GRPCClient.swift @@ -55,6 +55,7 @@ private import Synchronization /// additional resources that need their lifecycles managed you should consider using [Swift Service /// Lifecycle](https://github.com/swift-server/swift-service-lifecycle). @available(gRPCSwift 2.0, *) +@available(*, deprecated, message: "See https://forums.swift.org/t/80177") public final class GRPCClient: Sendable { /// The transport which provides a bidirectional communication channel with the server. private let transport: Transport @@ -399,6 +400,7 @@ public final class GRPCClient: Sendable { /// - handleClient: A closure which is called with the client. When the closure returns, the /// client is shutdown gracefully. @available(gRPCSwift 2.0, *) +@available(*, deprecated, message: "See https://forums.swift.org/t/80177") public func withGRPCClient( transport: Transport, interceptors: [any ClientInterceptor] = [], @@ -428,6 +430,7 @@ public func withGRPCClient( /// client is shutdown gracefully. /// - Returns: The result of the `handleClient` closure. @available(gRPCSwift 2.0, *) +@available(*, deprecated, message: "See https://forums.swift.org/t/80177") public func withGRPCClient( transport: Transport, interceptorPipeline: [ConditionalInterceptor], diff --git a/Sources/GRPCCore/GRPCServer.swift b/Sources/GRPCCore/GRPCServer.swift index d2ca1ed77..3aa55d3c4 100644 --- a/Sources/GRPCCore/GRPCServer.swift +++ b/Sources/GRPCCore/GRPCServer.swift @@ -76,6 +76,7 @@ private import Synchronization /// Lifecycle](https://github.com/swift-server/swift-service-lifecycle) and the /// `GRPCServiceLifecycle` module provided by [gRPC Swift Extras](https://github.com/grpc/grpc-swift-extras). @available(gRPCSwift 2.0, *) +@available(*, deprecated, message: "See https://forums.swift.org/t/80177") public final class GRPCServer: Sendable { typealias Stream = RPCStream @@ -259,6 +260,7 @@ public final class GRPCServer: Sendable { /// server is shutdown gracefully. /// - Returns: The result of the `handleServer` closure. @available(gRPCSwift 2.0, *) +@available(*, deprecated, message: "See https://forums.swift.org/t/80177") public func withGRPCServer( transport: Transport, services: [any RegistrableRPCService], @@ -291,6 +293,7 @@ public func withGRPCServer( /// server is shutdown gracefully. /// - Returns: The result of the `handleServer` closure. @available(gRPCSwift 2.0, *) +@available(*, deprecated, message: "See https://forums.swift.org/t/80177") public func withGRPCServer( transport: Transport, services: [any RegistrableRPCService], diff --git a/Sources/GRPCCore/Metadata.swift b/Sources/GRPCCore/Metadata.swift index 6c8263037..b3ea93810 100644 --- a/Sources/GRPCCore/Metadata.swift +++ b/Sources/GRPCCore/Metadata.swift @@ -80,6 +80,7 @@ /// the "-bin" suffix may have string values (rather than binary). These are deserialized automatically when /// using ``subscript(binaryValues:)``. @available(gRPCSwift 2.0, *) +@available(*, deprecated, message: "See https://forums.swift.org/t/80177") public struct Metadata: Sendable, Hashable { /// A metadata value. It can either be a simple string, or binary data. diff --git a/Sources/GRPCCore/Transport/ClientTransport.swift b/Sources/GRPCCore/Transport/ClientTransport.swift index 4b3cf6545..89d21e1c3 100644 --- a/Sources/GRPCCore/Transport/ClientTransport.swift +++ b/Sources/GRPCCore/Transport/ClientTransport.swift @@ -26,6 +26,7 @@ /// transport built on top of SwiftNIO in the https://github.com/grpc/grpc-swift-nio-transport /// package. @available(gRPCSwift 2.0, *) +@available(*, deprecated, message: "See https://forums.swift.org/t/80177") public protocol ClientTransport: Sendable { /// The bag-of-bytes type used by the transport. associatedtype Bytes: GRPCContiguousBytes & Sendable diff --git a/Sources/GRPCCore/Transport/ServerTransport.swift b/Sources/GRPCCore/Transport/ServerTransport.swift index d3891147d..62488a3bb 100644 --- a/Sources/GRPCCore/Transport/ServerTransport.swift +++ b/Sources/GRPCCore/Transport/ServerTransport.swift @@ -23,6 +23,7 @@ /// transport built on top of SwiftNIO in the https://github.com/grpc/grpc-swift-nio-transport /// package. @available(gRPCSwift 2.0, *) +@available(*, deprecated, message: "See https://forums.swift.org/t/80177") public protocol ServerTransport: Sendable { /// The bag-of-bytes type used by the transport. associatedtype Bytes: GRPCContiguousBytes & Sendable diff --git a/Sources/GRPCInProcessTransport/InProcessTransport.swift b/Sources/GRPCInProcessTransport/InProcessTransport.swift index 4dc5d3f83..3ceab8156 100644 --- a/Sources/GRPCInProcessTransport/InProcessTransport.swift +++ b/Sources/GRPCInProcessTransport/InProcessTransport.swift @@ -17,6 +17,7 @@ public import GRPCCore @available(gRPCSwift 2.0, *) +@available(*, deprecated, message: "See https://forums.swift.org/t/80177") public struct InProcessTransport: Sendable { public let server: Self.Server public let client: Self.Client From 73d6fbcbf6c60f0705ccd7eeaaf6fccf6efe731b Mon Sep 17 00:00:00 2001 From: George Barnett Date: Tue, 3 Jun 2025 14:27:07 +0100 Subject: [PATCH 2/4] Update generate --- dev/protos/generate.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dev/protos/generate.sh b/dev/protos/generate.sh index a4409f1d2..dec5de14c 100755 --- a/dev/protos/generate.sh +++ b/dev/protos/generate.sh @@ -21,7 +21,8 @@ protoc=$(which protoc) # Checkout and build the plugins. build_dir=$(mktemp -d) -git clone https://github.com/grpc/grpc-swift-protobuf --depth 1 "$build_dir" +git clone -b 1.3.0 https://github.com/grpc/grpc-swift-protobuf --depth 1 "$build_dir" + swift build --package-path "$build_dir" --product protoc-gen-swift swift build --package-path "$build_dir" --product protoc-gen-grpc-swift From 502b43a026b89ad9916bb0db9a4134057a662dfc Mon Sep 17 00:00:00 2001 From: George Barnett Date: Tue, 3 Jun 2025 15:58:53 +0100 Subject: [PATCH 3/4] update protos --- .../Configuration/Generated/rls.pb.swift | 30 +++++++++++-------- .../Generated/rls_config.pb.swift | 25 +++++++++------- .../Generated/service_config.pb.swift | 8 ----- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/Tests/GRPCCoreTests/Configuration/Generated/rls.pb.swift b/Tests/GRPCCoreTests/Configuration/Generated/rls.pb.swift index 36f8887af..003f6ff54 100644 --- a/Tests/GRPCCoreTests/Configuration/Generated/rls.pb.swift +++ b/Tests/GRPCCoreTests/Configuration/Generated/rls.pb.swift @@ -134,13 +134,16 @@ fileprivate let _protobuf_package = "grpc.lookup.v1" extension Grpc_Lookup_V1_RouteLookupRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = _protobuf_package + ".RouteLookupRequest" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 3: .standard(proto: "target_type"), - 5: .same(proto: "reason"), - 6: .standard(proto: "stale_header_data"), - 4: .standard(proto: "key_map"), - 7: .same(proto: "extensions"), - ] + static let _protobuf_nameMap = SwiftProtobuf._NameMap( + reservedNames: ["server", "path"], + reservedRanges: [1..<3], + numberNameMappings: [ + 3: .standard(proto: "target_type"), + 5: .same(proto: "reason"), + 6: .standard(proto: "stale_header_data"), + 4: .standard(proto: "key_map"), + 7: .same(proto: "extensions"), + ]) mutating func decodeMessage(decoder: inout D) throws { while let fieldNumber = try decoder.nextFieldNumber() { @@ -198,11 +201,14 @@ extension Grpc_Lookup_V1_RouteLookupRequest.Reason: SwiftProtobuf._ProtoNameProv extension Grpc_Lookup_V1_RouteLookupResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = _protobuf_package + ".RouteLookupResponse" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 3: .same(proto: "targets"), - 2: .standard(proto: "header_data"), - 4: .same(proto: "extensions"), - ] + static let _protobuf_nameMap = SwiftProtobuf._NameMap( + reservedNames: ["target"], + reservedRanges: [1..<2], + numberNameMappings: [ + 3: .same(proto: "targets"), + 2: .standard(proto: "header_data"), + 4: .same(proto: "extensions"), + ]) mutating func decodeMessage(decoder: inout D) throws { while let fieldNumber = try decoder.nextFieldNumber() { diff --git a/Tests/GRPCCoreTests/Configuration/Generated/rls_config.pb.swift b/Tests/GRPCCoreTests/Configuration/Generated/rls_config.pb.swift index bc6047eda..6ee5aa88f 100644 --- a/Tests/GRPCCoreTests/Configuration/Generated/rls_config.pb.swift +++ b/Tests/GRPCCoreTests/Configuration/Generated/rls_config.pb.swift @@ -587,17 +587,20 @@ extension Grpc_Lookup_V1_HttpKeyBuilder: SwiftProtobuf.Message, SwiftProtobuf._M extension Grpc_Lookup_V1_RouteLookupConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = _protobuf_package + ".RouteLookupConfig" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "http_keybuilders"), - 2: .standard(proto: "grpc_keybuilders"), - 3: .standard(proto: "lookup_service"), - 4: .standard(proto: "lookup_service_timeout"), - 5: .standard(proto: "max_age"), - 6: .standard(proto: "stale_age"), - 7: .standard(proto: "cache_size_bytes"), - 8: .standard(proto: "valid_targets"), - 9: .standard(proto: "default_target"), - ] + static let _protobuf_nameMap = SwiftProtobuf._NameMap( + reservedNames: ["request_processing_strategy"], + reservedRanges: [10..<11], + numberNameMappings: [ + 1: .standard(proto: "http_keybuilders"), + 2: .standard(proto: "grpc_keybuilders"), + 3: .standard(proto: "lookup_service"), + 4: .standard(proto: "lookup_service_timeout"), + 5: .standard(proto: "max_age"), + 6: .standard(proto: "stale_age"), + 7: .standard(proto: "cache_size_bytes"), + 8: .standard(proto: "valid_targets"), + 9: .standard(proto: "default_target"), + ]) mutating func decodeMessage(decoder: inout D) throws { while let fieldNumber = try decoder.nextFieldNumber() { diff --git a/Tests/GRPCCoreTests/Configuration/Generated/service_config.pb.swift b/Tests/GRPCCoreTests/Configuration/Generated/service_config.pb.swift index c25062a78..2cefad51d 100644 --- a/Tests/GRPCCoreTests/Configuration/Generated/service_config.pb.swift +++ b/Tests/GRPCCoreTests/Configuration/Generated/service_config.pb.swift @@ -2549,15 +2549,11 @@ extension Grpc_ServiceConfig_RlsLoadBalancingPolicyConfig: SwiftProtobuf.Message var _childPolicy: [Grpc_ServiceConfig_LoadBalancingConfig] = [] var _childPolicyConfigTargetFieldName: String = String() - #if swift(>=5.10) // This property is used as the initial default value for new instances of the type. // The type itself is protecting the reference to its storage via CoW semantics. // This will force a copy to be made of this reference when the first mutation occurs; // hence, it is safe to mark this as `nonisolated(unsafe)`. static nonisolated(unsafe) let defaultInstance = _StorageClass() - #else - static let defaultInstance = _StorageClass() - #endif private init() {} @@ -3692,15 +3688,11 @@ extension Grpc_ServiceConfig_XdsClusterResolverLoadBalancingPolicyConfig.Discove var _overrideHostStatus: [Grpc_ServiceConfig_OverrideHostLoadBalancingPolicyConfig.HealthStatus] = [] var _telemetryLabels: Dictionary = [:] - #if swift(>=5.10) // This property is used as the initial default value for new instances of the type. // The type itself is protecting the reference to its storage via CoW semantics. // This will force a copy to be made of this reference when the first mutation occurs; // hence, it is safe to mark this as `nonisolated(unsafe)`. static nonisolated(unsafe) let defaultInstance = _StorageClass() - #else - static let defaultInstance = _StorageClass() - #endif private init() {} From cac9484ec2fcc65b2c97998544e038175b2e8305 Mon Sep 17 00:00:00 2001 From: George Barnett Date: Tue, 3 Jun 2025 16:09:40 +0100 Subject: [PATCH 4/4] remove warnings as errors --- .github/workflows/pull_request.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index ed4bc8afe..2adc5ec34 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -22,8 +22,8 @@ jobs: with: linux_5_9_enabled: false linux_5_10_enabled: false - linux_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -warnings-as-errors -Xswiftc -require-explicit-availability" - linux_6_1_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -warnings-as-errors -Xswiftc -require-explicit-availability" + linux_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-availability" + linux_6_1_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-availability" linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-availability" linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-availability"