From aff076d24568b5c827aea87aae9f750444024dca Mon Sep 17 00:00:00 2001 From: George Barnett Date: Wed, 5 Apr 2023 17:42:50 +0100 Subject: [PATCH 1/2] Drop support for Swift 5.5 Motivation: Now that 5.8 has been released we can drop support for Swift 5.5. Modifications: - Update CI jobs - Remove conditional branches which are no longer supported - Update docs Result: Swift 5.6 is the lowest supported Swift version --- .github/workflows/ci.yaml | 31 +- .swiftformat | 2 +- Package@swift-5.5.swift | 470 ------------------ README.md | 5 +- .../Implementation/EchoAsyncProvider.swift | 3 - Sources/Examples/Echo/Model/echo.grpc.swift | 13 +- Sources/Examples/Echo/Runtime/Echo.swift | 12 - .../HelloWorld/Client/HelloWorldClient.swift | 9 - .../HelloWorld/Model/helloworld.grpc.swift | 11 +- .../HelloWorld/Server/GreeterProvider.swift | 2 - .../HelloWorld/Server/HelloWorldServer.swift | 9 - .../PacketCapture/PacketCapture.swift | 9 - .../RouteGuide/Client/RouteGuideClient.swift | 9 - .../RouteGuide/Model/route_guide.grpc.swift | 11 +- .../Server/RouteGuideProvider.swift | 4 - .../RouteGuide/Server/RouteGuideServer.swift | 9 - .../ServerHandlerStateMachine+Actions.swift | 2 - .../ServerHandlerStateMachine+Draining.swift | 2 - .../ServerHandlerStateMachine+Finished.swift | 2 - .../ServerHandlerStateMachine+Handling.swift | 2 - .../ServerHandlerStateMachine+Idle.swift | 2 - .../ServerHandlerStateMachine.swift | 2 - ...erverInterceptorStateMachine+Actions.swift | 2 - ...rverInterceptorStateMachine+Finished.swift | 2 - ...InterceptorStateMachine+Intercepting.swift | 2 - .../ServerInterceptorStateMachine.swift | 2 - .../StreamState.swift | 2 - .../Call+AsyncRequestStreamWriter.swift | 3 - ...llationError+GRPCStatusTransformable.swift | 4 - .../GRPCAsyncBidirectionalStreamingCall.swift | 4 - .../GRPCAsyncClientStreamingCall.swift | 4 - .../GRPCAsyncRequestStream.swift | 4 - .../GRPCAsyncRequestStreamWriter.swift | 3 - .../GRPCAsyncResponseStream.swift | 5 - .../GRPCAsyncResponseStreamWriter.swift | 4 - .../GRPCAsyncSequenceProducerDelegate.swift | 5 - .../GRPCAsyncServerCallContext.swift | 4 - .../GRPCAsyncServerHandler.swift | 3 - .../GRPCAsyncServerStreamingCall.swift | 4 - .../GRPCAsyncUnaryCall.swift | 4 - .../GRPCAsyncWriterSinkDelegate.swift | 3 - .../GRPCChannel+AsyncAwaitSupport.swift | 4 - .../GRPCClient+AsyncAwaitSupport.swift | 4 - .../GRPC/AsyncAwaitSupport/GRPCSendable.swift | 15 +- .../AsyncAwaitSupport/NIOAsyncWrappers.swift | 3 - Sources/GRPC/CallOptions.swift | 14 +- Sources/GRPC/ClientCalls/Call.swift | 2 - .../GRPC/ClientCalls/ResponseContainers.swift | 2 - Sources/GRPC/ClientConnection.swift | 54 +- Sources/GRPC/ClientErrorDelegate.swift | 3 +- .../Compression/CompressionAlgorithm.swift | 2 +- .../GRPC/Compression/DecompressionLimit.swift | 4 +- .../GRPC/Compression/MessageEncoding.swift | 8 +- Sources/GRPC/ConnectionBackoff.swift | 6 +- Sources/GRPC/ConnectionKeepalive.swift | 2 +- .../GRPC/ConnectionManager+Delegates.swift | 2 +- Sources/GRPC/ConnectionManager.swift | 6 +- .../ConnectionPool/ConnectionManagerID.swift | 2 +- .../GRPC/ConnectionPool/GRPCChannelPool.swift | 16 +- Sources/GRPC/ConnectionPool/PoolManager.swift | 2 - Sources/GRPC/ConnectivityState.swift | 11 +- Sources/GRPC/Docs.docc/index.md | 5 +- Sources/GRPC/FakeChannel.swift | 2 - Sources/GRPC/GRPCChannel/GRPCChannel.swift | 3 +- .../GRPC/GRPCChannel/GRPCChannelBuilder.swift | 10 - Sources/GRPC/GRPCClient.swift | 7 +- Sources/GRPC/GRPCClientChannelHandler.swift | 2 +- Sources/GRPC/GRPCServiceDescription.swift | 4 +- Sources/GRPC/GRPCStatus.swift | 6 +- Sources/GRPC/GRPCTLSConfiguration.swift | 4 +- .../GRPC/Interceptor/ClientInterceptors.swift | 52 -- Sources/GRPC/Interceptor/MessageParts.swift | 4 +- Sources/GRPC/TimeLimit.swift | 4 +- .../Generated/test.grpc.swift | 33 +- .../TestServiceAsyncProvider.swift | 2 - .../Generator-Client.swift | 9 +- .../Generator-Server.swift | 4 - Sources/protoc-gen-grpc-swift/Generator.swift | 8 - .../AsyncAwaitSupport/AsyncClientTests.swift | 3 - .../AsyncIntegrationTests.swift | 3 - .../AsyncSequence+Helpers.swift | 4 - .../ServerHandlerStateMachineTests.swift | 2 - ...erceptorStateMachineStreamStateTests.swift | 3 - .../ServerInterceptorStateMachineTests.swift | 3 - .../GRPCAsyncRequestStreamTests.swift | 3 - .../GRPCAsyncResponseStreamWriterTests.swift | 2 - .../InterceptorsAsyncTests.swift | 3 - .../AsyncAwaitSupport/XCTest+AsyncAwait.swift | 5 +- Tests/GRPCTests/ClientTimeoutTests.swift | 2 - .../Normalization/normalization.grpc.swift | 11 +- Tests/GRPCTests/ConnectionManagerTests.swift | 2 - .../ConnectionPoolDelegates.swift | 16 +- .../DelegatingErrorHandlerTests.swift | 4 +- .../EchoInterceptorFactories.swift | 4 - Tests/GRPCTests/EchoMetadataTests.swift | 2 - Tests/GRPCTests/ErrorRecordingDelegate.swift | 2 - .../GRPCTests/GRPCAsyncClientCallTests.swift | 6 +- .../GRPCAsyncServerHandlerTests.swift | 3 - .../GRPCTests/GRPCInteroperabilityTests.swift | 2 - Tests/GRPCTests/InterceptorsTests.swift | 2 - Tests/GRPCTests/XCTestHelpers.swift | 4 - 101 files changed, 88 insertions(+), 1009 deletions(-) delete mode 100644 Package@swift-5.5.swift diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 54a2a2534..a79d63662 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,7 +24,10 @@ jobs: fail-fast: false matrix: include: - - image: swiftlang/swift:nightly-5.8-focal + - image: swiftlang/swift:nightly-focal + # No TSAN because of: https://github.com/apple/swift/issues/59068 + # swift-test-flags: "--sanitize=thread" + - image: swift:5.8-jammy # No TSAN because of: https://github.com/apple/swift/issues/59068 # swift-test-flags: "--sanitize=thread" - image: swift:5.7-jammy @@ -33,8 +36,6 @@ jobs: - image: swift:5.6-focal # No TSAN because of: https://github.com/apple/swift/issues/59068 # swift-test-flags: "--sanitize=thread" - - image: swift:5.5-focal - swift-test-flags: "--sanitize=thread" name: Build and Test on ${{ matrix.image }} runs-on: ubuntu-latest container: @@ -54,7 +55,17 @@ jobs: fail-fast: false matrix: include: - - image: swiftlang/swift:nightly-5.8-focal + - image: swiftlang/swift:nightly-focal + env: + MAX_ALLOCS_ALLOWED_bidi_1k_rpcs_10_requests: 347000 + MAX_ALLOCS_ALLOWED_bidi_1k_rpcs_1_request: 167000 + MAX_ALLOCS_ALLOWED_embedded_server_bidi_1k_rpcs_10_small_requests: 109000 + MAX_ALLOCS_ALLOWED_embedded_server_bidi_1k_rpcs_1_small_request: 64000 + MAX_ALLOCS_ALLOWED_embedded_server_unary_1k_rpcs_1_small_request: 60000 + MAX_ALLOCS_ALLOWED_unary_1k_ping_pong: 169000 + MAX_ALLOCS_ALLOWED_unary_1k_ping_pong_interceptors_client: 176000 + MAX_ALLOCS_ALLOWED_unary_1k_ping_pong_interceptors_server: 176000 + - image: swift:5.8-jammy env: MAX_ALLOCS_ALLOWED_bidi_1k_rpcs_10_requests: 347000 MAX_ALLOCS_ALLOWED_bidi_1k_rpcs_1_request: 167000 @@ -84,16 +95,6 @@ jobs: MAX_ALLOCS_ALLOWED_unary_1k_ping_pong: 170000 MAX_ALLOCS_ALLOWED_unary_1k_ping_pong_interceptors_client: 177000 MAX_ALLOCS_ALLOWED_unary_1k_ping_pong_interceptors_server: 177000 - - image: swift:5.5-focal - env: - MAX_ALLOCS_ALLOWED_bidi_1k_rpcs_10_requests: 378000 - MAX_ALLOCS_ALLOWED_bidi_1k_rpcs_1_request: 180000 - MAX_ALLOCS_ALLOWED_embedded_server_bidi_1k_rpcs_10_small_requests: 109000 - MAX_ALLOCS_ALLOWED_embedded_server_bidi_1k_rpcs_1_small_request: 64000 - MAX_ALLOCS_ALLOWED_embedded_server_unary_1k_rpcs_1_small_request: 60000 - MAX_ALLOCS_ALLOWED_unary_1k_ping_pong: 181000 - MAX_ALLOCS_ALLOWED_unary_1k_ping_pong_interceptors_client: 188000 - MAX_ALLOCS_ALLOWED_unary_1k_ping_pong_interceptors_server: 188000 name: Performance Tests on ${{ matrix.image }} runs-on: ubuntu-latest @@ -111,9 +112,9 @@ jobs: matrix: include: - image: swiftlang/swift:nightly-focal + - image: swift:5.8-jammy - image: swift:5.7-jammy - image: swift:5.6-focal - - image: swift:5.5-focal name: Integration Tests on ${{ matrix.image }} runs-on: ubuntu-latest container: diff --git a/.swiftformat b/.swiftformat index 83b402ee9..9410761e8 100644 --- a/.swiftformat +++ b/.swiftformat @@ -1,5 +1,5 @@ # Language version. ---swiftversion 5.2 +--swiftversion 5.6 # Ignore generated files. --exclude **/LinuxMain.swift,**/XCTestManifests.swift,**/*.grpc.swift,**/*.pb.swift diff --git a/Package@swift-5.5.swift b/Package@swift-5.5.swift deleted file mode 100644 index ac90779eb..000000000 --- a/Package@swift-5.5.swift +++ /dev/null @@ -1,470 +0,0 @@ -// swift-tools-version:5.5 -/* - * Copyright 2022, gRPC Authors All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import PackageDescription -// swiftformat puts the next import before the tools version. -// swiftformat:disable:next sortedImports -import class Foundation.ProcessInfo - -let grpcPackageName = "grpc-swift" -let grpcProductName = "GRPC" -let cgrpcZlibProductName = "CGRPCZlib" -let grpcTargetName = grpcProductName -let cgrpcZlibTargetName = cgrpcZlibProductName - -let includeNIOSSL = ProcessInfo.processInfo.environment["GRPC_NO_NIO_SSL"] == nil - -// MARK: - Package Dependencies - -let packageDependencies: [Package.Dependency] = [ - .package( - url: "https://github.com/apple/swift-nio.git", - from: "2.42.0" - ), - .package( - url: "https://github.com/apple/swift-nio-http2.git", - from: "1.22.0" - ), - .package( - url: "https://github.com/apple/swift-nio-transport-services.git", - from: "1.15.0" - ), - .package( - url: "https://github.com/apple/swift-nio-extras.git", - from: "1.4.0" - ), - .package( - name: "SwiftProtobuf", - url: "https://github.com/apple/swift-protobuf.git", - from: "1.20.2" - ), - .package( - url: "https://github.com/apple/swift-log.git", - from: "1.4.0" - ), - .package( - url: "https://github.com/apple/swift-argument-parser.git", - from: "1.0.0" - ), -].appending( - .package( - url: "https://github.com/apple/swift-nio-ssl.git", - from: "2.23.0" - ), - if: includeNIOSSL -) - -// MARK: - Target Dependencies - -extension Target.Dependency { - // Target dependencies; external - static let grpc: Self = .target(name: grpcTargetName) - static let cgrpcZlib: Self = .target(name: cgrpcZlibTargetName) - static let protocGenGRPCSwift: Self = .target(name: "protoc-gen-grpc-swift") - - // Target dependencies; internal - static let grpcSampleData: Self = .target(name: "GRPCSampleData") - static let echoModel: Self = .target(name: "EchoModel") - static let echoImplementation: Self = .target(name: "EchoImplementation") - static let helloWorldModel: Self = .target(name: "HelloWorldModel") - static let routeGuideModel: Self = .target(name: "RouteGuideModel") - static let interopTestModels: Self = .target(name: "GRPCInteroperabilityTestModels") - static let interopTestImplementation: Self = - .target(name: "GRPCInteroperabilityTestsImplementation") - - // Product dependencies - static let argumentParser: Self = .product( - name: "ArgumentParser", - package: "swift-argument-parser" - ) - static let nio: Self = .product(name: "NIO", package: "swift-nio") - static let nioConcurrencyHelpers: Self = .product( - name: "NIOConcurrencyHelpers", - package: "swift-nio" - ) - static let nioCore: Self = .product(name: "NIOCore", package: "swift-nio") - static let nioEmbedded: Self = .product(name: "NIOEmbedded", package: "swift-nio") - static let nioExtras: Self = .product(name: "NIOExtras", package: "swift-nio-extras") - static let nioFoundationCompat: Self = .product(name: "NIOFoundationCompat", package: "swift-nio") - static let nioHTTP1: Self = .product(name: "NIOHTTP1", package: "swift-nio") - static let nioHTTP2: Self = .product(name: "NIOHTTP2", package: "swift-nio-http2") - static let nioPosix: Self = .product(name: "NIOPosix", package: "swift-nio") - static let nioSSL: Self = .product(name: "NIOSSL", package: "swift-nio-ssl") - static let nioTLS: Self = .product(name: "NIOTLS", package: "swift-nio") - static let nioTransportServices: Self = .product( - name: "NIOTransportServices", - package: "swift-nio-transport-services" - ) - static let logging: Self = .product(name: "Logging", package: "swift-log") - static let protobuf: Self = .product(name: "SwiftProtobuf", package: "SwiftProtobuf") - static let protobufPluginLibrary: Self = .product( - name: "SwiftProtobufPluginLibrary", - package: "SwiftProtobuf" - ) -} - -// MARK: - Targets - -extension Target { - static let grpc: Target = .target( - name: grpcTargetName, - dependencies: [ - .cgrpcZlib, - .nio, - .nioCore, - .nioPosix, - .nioEmbedded, - .nioFoundationCompat, - .nioTLS, - .nioTransportServices, - .nioHTTP1, - .nioHTTP2, - .nioExtras, - .logging, - .protobuf, - ].appending( - .nioSSL, if: includeNIOSSL - ), - path: "Sources/GRPC" - ) - - static let cgrpcZlib: Target = .target( - name: cgrpcZlibTargetName, - path: "Sources/CGRPCZlib", - linkerSettings: [ - .linkedLibrary("z"), - ] - ) - - static let protocGenGRPCSwift: Target = .executableTarget( - name: "protoc-gen-grpc-swift", - dependencies: [ - .protobuf, - .protobufPluginLibrary, - ], - exclude: [ - "README.md", - ] - ) - - static let grpcTests: Target = .testTarget( - name: "GRPCTests", - dependencies: [ - .grpc, - .echoModel, - .echoImplementation, - .helloWorldModel, - .interopTestModels, - .interopTestImplementation, - .grpcSampleData, - .nioCore, - .nioConcurrencyHelpers, - .nioPosix, - .nioTLS, - .nioHTTP1, - .nioHTTP2, - .nioEmbedded, - .nioTransportServices, - .logging, - ].appending( - .nioSSL, if: includeNIOSSL - ), - exclude: [ - "Codegen/Normalization/normalization.proto", - ] - ) - - static let interopTestModels: Target = .target( - name: "GRPCInteroperabilityTestModels", - dependencies: [ - .grpc, - .nio, - .protobuf, - ], - exclude: [ - "README.md", - "generate.sh", - "src/proto/grpc/testing/empty.proto", - "src/proto/grpc/testing/empty_service.proto", - "src/proto/grpc/testing/messages.proto", - "src/proto/grpc/testing/test.proto", - "unimplemented_call.patch", - ] - ) - - static let interopTestImplementation: Target = .target( - name: "GRPCInteroperabilityTestsImplementation", - dependencies: [ - .grpc, - .interopTestModels, - .nioCore, - .nioPosix, - .nioHTTP1, - .logging, - ].appending( - .nioSSL, if: includeNIOSSL - ) - ) - - static let interopTests: Target = .executableTarget( - name: "GRPCInteroperabilityTests", - dependencies: [ - .grpc, - .interopTestImplementation, - .nioCore, - .nioPosix, - .logging, - .argumentParser, - ] - ) - - static let backoffInteropTest: Target = .executableTarget( - name: "GRPCConnectionBackoffInteropTest", - dependencies: [ - .grpc, - .interopTestModels, - .nioCore, - .nioPosix, - .logging, - .argumentParser, - ], - exclude: [ - "README.md", - ] - ) - - static let perfTests: Target = .executableTarget( - name: "GRPCPerformanceTests", - dependencies: [ - .grpc, - .grpcSampleData, - .nioCore, - .nioEmbedded, - .nioPosix, - .nioHTTP2, - .argumentParser, - ] - ) - - static let grpcSampleData: Target = .target( - name: "GRPCSampleData", - dependencies: includeNIOSSL ? [.nioSSL] : [], - exclude: [ - "bundle.p12", - ] - ) - - static let echoModel: Target = .target( - name: "EchoModel", - dependencies: [ - .grpc, - .nio, - .protobuf, - ], - path: "Sources/Examples/Echo/Model", - exclude: [ - "echo.proto", - ] - ) - - static let echoImplementation: Target = .target( - name: "EchoImplementation", - dependencies: [ - .echoModel, - .grpc, - .nioCore, - .nioHTTP2, - .protobuf, - ], - path: "Sources/Examples/Echo/Implementation" - ) - - static let echo: Target = .executableTarget( - name: "Echo", - dependencies: [ - .grpc, - .echoModel, - .echoImplementation, - .grpcSampleData, - .nioCore, - .nioPosix, - .logging, - .argumentParser, - ].appending( - .nioSSL, if: includeNIOSSL - ), - path: "Sources/Examples/Echo/Runtime" - ) - - static let helloWorldModel: Target = .target( - name: "HelloWorldModel", - dependencies: [ - .grpc, - .nio, - .protobuf, - ], - path: "Sources/Examples/HelloWorld/Model", - exclude: [ - "helloworld.proto", - ] - ) - - static let helloWorldClient: Target = .executableTarget( - name: "HelloWorldClient", - dependencies: [ - .grpc, - .helloWorldModel, - .nioCore, - .nioPosix, - .argumentParser, - ], - path: "Sources/Examples/HelloWorld/Client" - ) - - static let helloWorldServer: Target = .executableTarget( - name: "HelloWorldServer", - dependencies: [ - .grpc, - .helloWorldModel, - .nioCore, - .nioPosix, - .argumentParser, - ], - path: "Sources/Examples/HelloWorld/Server" - ) - - static let routeGuideModel: Target = .target( - name: "RouteGuideModel", - dependencies: [ - .grpc, - .nio, - .protobuf, - ], - path: "Sources/Examples/RouteGuide/Model", - exclude: [ - "route_guide.proto", - ] - ) - - static let routeGuideClient: Target = .executableTarget( - name: "RouteGuideClient", - dependencies: [ - .grpc, - .routeGuideModel, - .nioCore, - .nioPosix, - .argumentParser, - ], - path: "Sources/Examples/RouteGuide/Client" - ) - - static let routeGuideServer: Target = .executableTarget( - name: "RouteGuideServer", - dependencies: [ - .grpc, - .routeGuideModel, - .nioCore, - .nioConcurrencyHelpers, - .nioPosix, - .argumentParser, - ], - path: "Sources/Examples/RouteGuide/Server" - ) - - static let packetCapture: Target = .executableTarget( - name: "PacketCapture", - dependencies: [ - .grpc, - .echoModel, - .nioCore, - .nioPosix, - .nioExtras, - .argumentParser, - ], - path: "Sources/Examples/PacketCapture", - exclude: [ - "README.md", - ] - ) -} - -// MARK: - Products - -extension Product { - static let grpc: Product = .library( - name: grpcProductName, - targets: [grpcTargetName] - ) - - static let cgrpcZlib: Product = .library( - name: cgrpcZlibProductName, - targets: [cgrpcZlibTargetName] - ) - - static let protocGenGRPCSwift: Product = .executable( - name: "protoc-gen-grpc-swift", - targets: ["protoc-gen-grpc-swift"] - ) -} - -// MARK: - Package - -let package = Package( - name: grpcPackageName, - products: [ - .grpc, - .cgrpcZlib, - .protocGenGRPCSwift, - ], - dependencies: packageDependencies, - targets: [ - // Products - .grpc, - .cgrpcZlib, - .protocGenGRPCSwift, - - // Tests etc. - .grpcTests, - .interopTestModels, - .interopTestImplementation, - .interopTests, - .backoffInteropTest, - .perfTests, - .grpcSampleData, - - // Examples - .echoModel, - .echoImplementation, - .echo, - .helloWorldModel, - .helloWorldClient, - .helloWorldServer, - .routeGuideModel, - .routeGuideClient, - .routeGuideServer, - .packetCapture, - ] -) - -extension Array { - func appending(_ element: Element, if condition: Bool) -> [Element] { - if condition { - return self + [element] - } else { - return self - } - } -} diff --git a/README.md b/README.md index cc337a324..f58727738 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,8 @@ gRPC Swift Version | Earliest Swift Version -------------------|----------------------- `1.0.0 ..< 1.8.0` | 5.2 `1.8.0 ..< 1.11.0` | 5.4 -`1.11.0...` | 5.5 +`1.11.0..< 1.16.0`.| 5.5 +`1.16.0...` | 5.6 Versions of clients and services which are use Swift's Concurrency support are available from gRPC Swift 1.8.0 and require Swift 5.6 and newer. @@ -59,7 +60,7 @@ package dependency to your `Package.swift`: ```swift dependencies: [ - .package(url: "https://github.com/grpc/grpc-swift.git", from: "1.9.0") + .package(url: "https://github.com/grpc/grpc-swift.git", from: "1.15.0") ] ``` diff --git a/Sources/Examples/Echo/Implementation/EchoAsyncProvider.swift b/Sources/Examples/Echo/Implementation/EchoAsyncProvider.swift index 166392c58..0c06abeb5 100644 --- a/Sources/Examples/Echo/Implementation/EchoAsyncProvider.swift +++ b/Sources/Examples/Echo/Implementation/EchoAsyncProvider.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import EchoModel import GRPC @@ -68,5 +67,3 @@ public final class EchoAsyncProvider: Echo_EchoAsyncProvider { } } } - -#endif // compiler(>=5.6) diff --git a/Sources/Examples/Echo/Model/echo.grpc.swift b/Sources/Examples/Echo/Model/echo.grpc.swift index 900fbd2d5..f1bd21112 100644 --- a/Sources/Examples/Echo/Model/echo.grpc.swift +++ b/Sources/Examples/Echo/Model/echo.grpc.swift @@ -136,10 +136,8 @@ extension Echo_EchoClientProtocol { } } -#if compiler(>=5.6) @available(*, deprecated) extension Echo_EchoClient: @unchecked Sendable {} -#endif // compiler(>=5.6) @available(*, deprecated, renamed: "Echo_EchoNIOClient") public final class Echo_EchoClient: Echo_EchoClientProtocol { @@ -195,7 +193,6 @@ public struct Echo_EchoNIOClient: Echo_EchoClientProtocol { } } -#if compiler(>=5.6) @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public protocol Echo_EchoAsyncClientProtocol: GRPCClient { static var serviceDescriptor: GRPCServiceDescriptor { get } @@ -367,9 +364,7 @@ public struct Echo_EchoAsyncClient: Echo_EchoAsyncClientProtocol { } } -#endif // compiler(>=5.6) - -public protocol Echo_EchoClientInterceptorFactoryProtocol: GRPCSendable { +public protocol Echo_EchoClientInterceptorFactoryProtocol: Sendable { /// - Returns: Interceptors to use when invoking 'get'. func makeGetInterceptors() -> [ClientInterceptor] @@ -423,10 +418,8 @@ public enum Echo_EchoClientMetadata { } } -#if compiler(>=5.6) @available(swift, deprecated: 5.6) extension Echo_EchoTestClient: @unchecked Sendable {} -#endif // compiler(>=5.6) @available(swift, deprecated: 5.6, message: "Test clients are not Sendable but the 'GRPCClient' API requires clients to be Sendable. Using a localhost client and server is the recommended alternative.") public final class Echo_EchoTestClient: Echo_EchoClientProtocol { @@ -618,8 +611,6 @@ extension Echo_EchoProvider { } } -#if compiler(>=5.6) - /// To implement a server, implement an object which conforms to this protocol. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public protocol Echo_EchoAsyncProvider: CallHandlerProvider { @@ -714,8 +705,6 @@ extension Echo_EchoAsyncProvider { } } -#endif // compiler(>=5.6) - public protocol Echo_EchoServerInterceptorFactoryProtocol { /// - Returns: Interceptors to use when handling 'get'. diff --git a/Sources/Examples/Echo/Runtime/Echo.swift b/Sources/Examples/Echo/Runtime/Echo.swift index b8ee8c40d..65abd883d 100644 --- a/Sources/Examples/Echo/Runtime/Echo.swift +++ b/Sources/Examples/Echo/Runtime/Echo.swift @@ -13,9 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -#if compiler(>=5.6) - import ArgumentParser import EchoImplementation import EchoModel @@ -246,12 +243,3 @@ func echoUpdate(client: Echo_EchoAsyncClient, message: String) async throws { print("update received: \(response.text)") } } - -#else -@main -enum Echo { - static func main() { - print("This example requires Swift >= 5.6") - } -} -#endif diff --git a/Sources/Examples/HelloWorld/Client/HelloWorldClient.swift b/Sources/Examples/HelloWorld/Client/HelloWorldClient.swift index 41de5df33..253e7c19c 100644 --- a/Sources/Examples/HelloWorld/Client/HelloWorldClient.swift +++ b/Sources/Examples/HelloWorld/Client/HelloWorldClient.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import ArgumentParser import GRPC import HelloWorldModel @@ -68,11 +67,3 @@ struct HelloWorld: AsyncParsableCommand { } } } -#else -@main -enum HelloWorld { - static func main() { - fatalError("This example requires swift >= 5.6") - } -} -#endif // compiler(>=5.6) diff --git a/Sources/Examples/HelloWorld/Model/helloworld.grpc.swift b/Sources/Examples/HelloWorld/Model/helloworld.grpc.swift index b5883f387..cc229bcab 100644 --- a/Sources/Examples/HelloWorld/Model/helloworld.grpc.swift +++ b/Sources/Examples/HelloWorld/Model/helloworld.grpc.swift @@ -63,10 +63,8 @@ extension Helloworld_GreeterClientProtocol { } } -#if compiler(>=5.6) @available(*, deprecated) extension Helloworld_GreeterClient: @unchecked Sendable {} -#endif // compiler(>=5.6) @available(*, deprecated, renamed: "Helloworld_GreeterNIOClient") public final class Helloworld_GreeterClient: Helloworld_GreeterClientProtocol { @@ -122,7 +120,6 @@ public struct Helloworld_GreeterNIOClient: Helloworld_GreeterClientProtocol { } } -#if compiler(>=5.6) /// The greeting service definition. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public protocol Helloworld_GreeterAsyncClientProtocol: GRPCClient { @@ -190,9 +187,7 @@ public struct Helloworld_GreeterAsyncClient: Helloworld_GreeterAsyncClientProtoc } } -#endif // compiler(>=5.6) - -public protocol Helloworld_GreeterClientInterceptorFactoryProtocol: GRPCSendable { +public protocol Helloworld_GreeterClientInterceptorFactoryProtocol: Sendable { /// - Returns: Interceptors to use when invoking 'sayHello'. func makeSayHelloInterceptors() -> [ClientInterceptor] @@ -253,8 +248,6 @@ extension Helloworld_GreeterProvider { } } -#if compiler(>=5.6) - /// The greeting service definition. /// /// To implement a server, implement an object which conforms to this protocol. @@ -304,8 +297,6 @@ extension Helloworld_GreeterAsyncProvider { } } -#endif // compiler(>=5.6) - public protocol Helloworld_GreeterServerInterceptorFactoryProtocol { /// - Returns: Interceptors to use when handling 'sayHello'. diff --git a/Sources/Examples/HelloWorld/Server/GreeterProvider.swift b/Sources/Examples/HelloWorld/Server/GreeterProvider.swift index d4be35bef..bf6ea4449 100644 --- a/Sources/Examples/HelloWorld/Server/GreeterProvider.swift +++ b/Sources/Examples/HelloWorld/Server/GreeterProvider.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import GRPC import HelloWorldModel import NIOCore @@ -32,4 +31,3 @@ final class GreeterProvider: Helloworld_GreeterAsyncProvider { } } } -#endif // compiler(>=5.6) diff --git a/Sources/Examples/HelloWorld/Server/HelloWorldServer.swift b/Sources/Examples/HelloWorld/Server/HelloWorldServer.swift index aa78f86f0..038728a9f 100644 --- a/Sources/Examples/HelloWorld/Server/HelloWorldServer.swift +++ b/Sources/Examples/HelloWorld/Server/HelloWorldServer.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import ArgumentParser import GRPC import HelloWorldModel @@ -44,11 +43,3 @@ struct HelloWorld: AsyncParsableCommand { try await server.onClose.get() } } -#else -@main -enum HelloWorld { - static func main() { - fatalError("This example requires swift >= 5.6") - } -} -#endif // compiler(>=5.6) diff --git a/Sources/Examples/PacketCapture/PacketCapture.swift b/Sources/Examples/PacketCapture/PacketCapture.swift index 15178576e..8d1544b47 100644 --- a/Sources/Examples/PacketCapture/PacketCapture.swift +++ b/Sources/Examples/PacketCapture/PacketCapture.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import ArgumentParser import EchoModel import GRPC @@ -84,11 +83,3 @@ struct PCAP: AsyncParsableCommand { try await echo.channel.close().get() } } -#else -@main -enum PCAP { - static func main() { - print("This example requires Swift >= 5.6") - } -} -#endif // compiler(>=5.6) diff --git a/Sources/Examples/RouteGuide/Client/RouteGuideClient.swift b/Sources/Examples/RouteGuide/Client/RouteGuideClient.swift index c6d416a5a..47710deef 100644 --- a/Sources/Examples/RouteGuide/Client/RouteGuideClient.swift +++ b/Sources/Examples/RouteGuide/Client/RouteGuideClient.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import ArgumentParser import Foundation import GRPC @@ -247,11 +246,3 @@ extension Routeguide_Feature: CustomStringConvertible { return "\(self.name) at \(self.location)" } } -#else -@main -enum NotAvailable { - static func main() { - print("This example requires Swift >= 5.6") - } -} -#endif // compiler(>=5.6) diff --git a/Sources/Examples/RouteGuide/Model/route_guide.grpc.swift b/Sources/Examples/RouteGuide/Model/route_guide.grpc.swift index 641d470cf..e8ab16682 100644 --- a/Sources/Examples/RouteGuide/Model/route_guide.grpc.swift +++ b/Sources/Examples/RouteGuide/Model/route_guide.grpc.swift @@ -154,10 +154,8 @@ extension Routeguide_RouteGuideClientProtocol { } } -#if compiler(>=5.6) @available(*, deprecated) extension Routeguide_RouteGuideClient: @unchecked Sendable {} -#endif // compiler(>=5.6) @available(*, deprecated, renamed: "Routeguide_RouteGuideNIOClient") public final class Routeguide_RouteGuideClient: Routeguide_RouteGuideClientProtocol { @@ -213,7 +211,6 @@ public struct Routeguide_RouteGuideNIOClient: Routeguide_RouteGuideClientProtoco } } -#if compiler(>=5.6) /// Interface exported by the server. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public protocol Routeguide_RouteGuideAsyncClientProtocol: GRPCClient { @@ -386,9 +383,7 @@ public struct Routeguide_RouteGuideAsyncClient: Routeguide_RouteGuideAsyncClient } } -#endif // compiler(>=5.6) - -public protocol Routeguide_RouteGuideClientInterceptorFactoryProtocol: GRPCSendable { +public protocol Routeguide_RouteGuideClientInterceptorFactoryProtocol: Sendable { /// - Returns: Interceptors to use when invoking 'getFeature'. func makeGetFeatureInterceptors() -> [ClientInterceptor] @@ -531,8 +526,6 @@ extension Routeguide_RouteGuideProvider { } } -#if compiler(>=5.6) - /// Interface exported by the server. /// /// To implement a server, implement an object which conforms to this protocol. @@ -645,8 +638,6 @@ extension Routeguide_RouteGuideAsyncProvider { } } -#endif // compiler(>=5.6) - public protocol Routeguide_RouteGuideServerInterceptorFactoryProtocol { /// - Returns: Interceptors to use when handling 'getFeature'. diff --git a/Sources/Examples/RouteGuide/Server/RouteGuideProvider.swift b/Sources/Examples/RouteGuide/Server/RouteGuideProvider.swift index 301a56e02..63fa450b5 100644 --- a/Sources/Examples/RouteGuide/Server/RouteGuideProvider.swift +++ b/Sources/Examples/RouteGuide/Server/RouteGuideProvider.swift @@ -19,8 +19,6 @@ import NIOConcurrencyHelpers import NIOCore import RouteGuideModel -#if compiler(>=5.6) - @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) internal final class RouteGuideProvider: Routeguide_RouteGuideAsyncProvider { private let features: [Routeguide_Feature] @@ -130,8 +128,6 @@ internal final actor Notes { } } -#endif // compiler(>=5.6) - private func degreesToRadians(_ degrees: Double) -> Double { return degrees * .pi / 180.0 } diff --git a/Sources/Examples/RouteGuide/Server/RouteGuideServer.swift b/Sources/Examples/RouteGuide/Server/RouteGuideServer.swift index 192478bc6..02af3b2b6 100644 --- a/Sources/Examples/RouteGuide/Server/RouteGuideServer.swift +++ b/Sources/Examples/RouteGuide/Server/RouteGuideServer.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import ArgumentParser import struct Foundation.Data import struct Foundation.URL @@ -64,11 +63,3 @@ struct RouteGuide: AsyncParsableCommand { try await server.onClose.get() } } -#else -@main -enum RouteGuide { - static func main() { - print("This example requires Swift >= 5.6") - } -} -#endif // compiler(>=5.6) diff --git a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine+Actions.swift b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine+Actions.swift index 8c75f0e5e..80b5cf67a 100644 --- a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine+Actions.swift +++ b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine+Actions.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import NIOHPACK @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) @@ -94,4 +93,3 @@ extension ServerHandlerStateMachine { } } } -#endif // compiler(>=5.6) diff --git a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine+Draining.swift b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine+Draining.swift index 857beda70..5aa1f58eb 100644 --- a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine+Draining.swift +++ b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine+Draining.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import NIOHPACK @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) @@ -107,4 +106,3 @@ extension ServerHandlerStateMachine { } } } -#endif // compiler(>=5.6) diff --git a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine+Finished.swift b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine+Finished.swift index c9637a1f0..5395775b9 100644 --- a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine+Finished.swift +++ b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine+Finished.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import NIOHPACK @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) @@ -78,4 +77,3 @@ extension ServerHandlerStateMachine { } } } -#endif // compiler(>=5.6) diff --git a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine+Handling.swift b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine+Handling.swift index a05787d86..7dd6340fb 100644 --- a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine+Handling.swift +++ b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine+Handling.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import NIOHPACK @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) @@ -110,4 +109,3 @@ extension ServerHandlerStateMachine { } } } -#endif // compiler(>=5.6) diff --git a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine+Idle.swift b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine+Idle.swift index fa51bcd4b..a017bddac 100644 --- a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine+Idle.swift +++ b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine+Idle.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import NIOHPACK @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) @@ -78,4 +77,3 @@ extension ServerHandlerStateMachine { } } } -#endif // compiler(>=5.6) diff --git a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine.swift b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine.swift index f0ab4fa77..3e7098a98 100644 --- a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine.swift +++ b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachine.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import NIOHPACK @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) @@ -359,4 +358,3 @@ extension ServerHandlerStateMachine.Finished { } } } -#endif // compiler(>=5.6) diff --git a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachine+Actions.swift b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachine+Actions.swift index dd3231059..c570e20b6 100644 --- a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachine+Actions.swift +++ b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachine+Actions.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) extension ServerInterceptorStateMachine { @usableFromInline enum InterceptAction: Hashable { @@ -65,4 +64,3 @@ extension ServerInterceptorStateMachine { case none } } -#endif // compiler(>=5.6) diff --git a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachine+Finished.swift b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachine+Finished.swift index 483240d50..3c1a2445f 100644 --- a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachine+Finished.swift +++ b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachine+Finished.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) extension ServerInterceptorStateMachine { /// The 'Finished' state is, as the name suggests, a terminal state. Nothing can happen in this /// state. @@ -91,4 +90,3 @@ extension ServerInterceptorStateMachine { } } } -#endif // compiler(>=5.6) diff --git a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachine+Intercepting.swift b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachine+Intercepting.swift index 0d0a19e9b..2596b319e 100644 --- a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachine+Intercepting.swift +++ b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachine+Intercepting.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) extension ServerInterceptorStateMachine { /// The 'Intercepting' state is responsible for validating that appropriate message parts are /// forwarded to the interceptor pipeline and that messages parts which have been emitted from the @@ -138,4 +137,3 @@ extension ServerInterceptorStateMachine { } } } -#endif // compiler(>=5.6) diff --git a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachine.swift b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachine.swift index 8863bc6b6..cbbecf8d0 100644 --- a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachine.swift +++ b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachine.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) @usableFromInline internal struct ServerInterceptorStateMachine { @usableFromInline @@ -283,4 +282,3 @@ extension ServerInterceptorStateMachine.Finished { } } } -#endif // compiler(>=5.6) diff --git a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/StreamState.swift b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/StreamState.swift index 2ba686209..5fddb3c39 100644 --- a/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/StreamState.swift +++ b/Sources/GRPC/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/StreamState.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) extension ServerInterceptorStateMachine { @usableFromInline internal enum StreamFilter: Hashable { @@ -99,4 +98,3 @@ extension ServerInterceptorStateMachine { } } } -#endif // compiler(>=5.6) diff --git a/Sources/GRPC/AsyncAwaitSupport/Call+AsyncRequestStreamWriter.swift b/Sources/GRPC/AsyncAwaitSupport/Call+AsyncRequestStreamWriter.swift index 57480f356..720ced509 100644 --- a/Sources/GRPC/AsyncAwaitSupport/Call+AsyncRequestStreamWriter.swift +++ b/Sources/GRPC/AsyncAwaitSupport/Call+AsyncRequestStreamWriter.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import NIOCore @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) @@ -45,5 +44,3 @@ extension Call where Request: Sendable, Response: Sendable { return (GRPCAsyncRequestStreamWriter(asyncWriter: writer.writer), writer.sink) } } - -#endif // compiler(>=5.6) diff --git a/Sources/GRPC/AsyncAwaitSupport/CancellationError+GRPCStatusTransformable.swift b/Sources/GRPC/AsyncAwaitSupport/CancellationError+GRPCStatusTransformable.swift index 3539860f9..a64ba5955 100644 --- a/Sources/GRPC/AsyncAwaitSupport/CancellationError+GRPCStatusTransformable.swift +++ b/Sources/GRPC/AsyncAwaitSupport/CancellationError+GRPCStatusTransformable.swift @@ -14,13 +14,9 @@ * limitations under the License. */ -#if compiler(>=5.6) - @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) extension CancellationError: GRPCStatusTransformable { public func makeGRPCStatus() -> GRPCStatus { return GRPCStatus(code: .unavailable, message: nil) } } - -#endif diff --git a/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncBidirectionalStreamingCall.swift b/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncBidirectionalStreamingCall.swift index 26c20e501..690e113f1 100644 --- a/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncBidirectionalStreamingCall.swift +++ b/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncBidirectionalStreamingCall.swift @@ -13,8 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) - import NIOCore import NIOHPACK @@ -187,5 +185,3 @@ internal enum AsyncCall { } } } - -#endif diff --git a/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncClientStreamingCall.swift b/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncClientStreamingCall.swift index 3c37f5691..cc006e5d2 100644 --- a/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncClientStreamingCall.swift +++ b/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncClientStreamingCall.swift @@ -13,8 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) - import NIOCore import NIOHPACK @@ -110,5 +108,3 @@ public struct GRPCAsyncClientStreamingCall=5.6) import NIOCore /// A type for the stream of request messages send to a gRPC server method. @@ -158,5 +156,3 @@ public struct GRPCAsyncRequestStream: AsyncSequence { @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) extension GRPCAsyncRequestStream: Sendable where Element: Sendable {} - -#endif diff --git a/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncRequestStreamWriter.swift b/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncRequestStreamWriter.swift index 7bfe524c0..9516d00a6 100644 --- a/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncRequestStreamWriter.swift +++ b/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncRequestStreamWriter.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import NIOCore /// An object allowing the holder -- a client -- to send requests on an RPC. @@ -95,5 +94,3 @@ public struct GRPCAsyncRequestStreamWriter: Sendable { self.asyncWriter.finish(error: error) } } - -#endif // compiler(>=5.6) diff --git a/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncResponseStream.swift b/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncResponseStream.swift index dc4bb6747..225fa31d8 100644 --- a/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncResponseStream.swift +++ b/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncResponseStream.swift @@ -13,9 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -#if compiler(>=5.6) - import NIOCore /// This is currently a wrapper around AsyncThrowingStream because we want to be @@ -60,5 +57,3 @@ public struct GRPCAsyncResponseStream: AsyncSequence { @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) extension GRPCAsyncResponseStream: Sendable {} - -#endif diff --git a/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncResponseStreamWriter.swift b/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncResponseStreamWriter.swift index 3d06c007f..c00490c8a 100644 --- a/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncResponseStreamWriter.swift +++ b/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncResponseStreamWriter.swift @@ -13,8 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -#if compiler(>=5.6) import NIOCore /// Writer for server-streaming RPC handlers to provide responses. @@ -168,5 +166,3 @@ public struct GRPCAsyncResponseStreamWriter: Sendable { return TestingStreamWriter(writer: writer, stream: responseStream) } } - -#endif diff --git a/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncSequenceProducerDelegate.swift b/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncSequenceProducerDelegate.swift index 817a48e2a..baca7ba91 100644 --- a/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncSequenceProducerDelegate.swift +++ b/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncSequenceProducerDelegate.swift @@ -13,9 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -#if compiler(>=5.6) - import NIOCore @usableFromInline @@ -31,5 +28,3 @@ internal struct GRPCAsyncSequenceProducerDelegate: NIOAsyncSequenceProducerDeleg @inlinable internal func didTerminate() {} } - -#endif diff --git a/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncServerCallContext.swift b/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncServerCallContext.swift index 7b2ee6c3f..73da1c527 100644 --- a/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncServerCallContext.swift +++ b/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncServerCallContext.swift @@ -13,8 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) - import Logging import NIOConcurrencyHelpers import NIOHPACK @@ -115,5 +113,3 @@ extension GRPCAsyncServerCallContext { } } } - -#endif diff --git a/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncServerHandler.swift b/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncServerHandler.swift index fb3bf311a..02a237694 100644 --- a/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncServerHandler.swift +++ b/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncServerHandler.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import DequeModule import Logging import NIOCore @@ -860,5 +859,3 @@ internal struct ServerHandlerComponents< self.task.cancel() } } - -#endif // compiler(>=5.6) diff --git a/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncServerStreamingCall.swift b/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncServerStreamingCall.swift index 03a7075c6..2fddbba4b 100644 --- a/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncServerStreamingCall.swift +++ b/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncServerStreamingCall.swift @@ -14,8 +14,6 @@ * limitations under the License. */ -#if compiler(>=5.6) - import NIOCore import NIOHPACK @@ -128,5 +126,3 @@ public struct GRPCAsyncServerStreamingCall=5.6) - import NIOHPACK /// A unary gRPC call. The request is sent on initialization. @@ -104,5 +102,3 @@ public struct GRPCAsyncUnaryCall: Sendabl Self(call: call, request) } } - -#endif diff --git a/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncWriterSinkDelegate.swift b/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncWriterSinkDelegate.swift index 3cfa6f13c..9e9b088a2 100644 --- a/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncWriterSinkDelegate.swift +++ b/Sources/GRPC/AsyncAwaitSupport/GRPCAsyncWriterSinkDelegate.swift @@ -13,8 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -#if compiler(>=5.6) import DequeModule import NIOCore @@ -45,4 +43,3 @@ internal struct GRPCAsyncWriterSinkDelegate: NIOAsyncWriterSi self._didTerminate?(error) } } -#endif // compiler(>=5.6) diff --git a/Sources/GRPC/AsyncAwaitSupport/GRPCChannel+AsyncAwaitSupport.swift b/Sources/GRPC/AsyncAwaitSupport/GRPCChannel+AsyncAwaitSupport.swift index 8e781246b..fff10db18 100644 --- a/Sources/GRPC/AsyncAwaitSupport/GRPCChannel+AsyncAwaitSupport.swift +++ b/Sources/GRPC/AsyncAwaitSupport/GRPCChannel+AsyncAwaitSupport.swift @@ -13,8 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) - import SwiftProtobuf @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) @@ -223,5 +221,3 @@ extension GRPCChannel { ) } } - -#endif diff --git a/Sources/GRPC/AsyncAwaitSupport/GRPCClient+AsyncAwaitSupport.swift b/Sources/GRPC/AsyncAwaitSupport/GRPCClient+AsyncAwaitSupport.swift index 8f675cf78..91ba44eae 100644 --- a/Sources/GRPC/AsyncAwaitSupport/GRPCClient+AsyncAwaitSupport.swift +++ b/Sources/GRPC/AsyncAwaitSupport/GRPCClient+AsyncAwaitSupport.swift @@ -13,8 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) - import SwiftProtobuf @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) @@ -481,5 +479,3 @@ extension AsyncStream { } } } - -#endif diff --git a/Sources/GRPC/AsyncAwaitSupport/GRPCSendable.swift b/Sources/GRPC/AsyncAwaitSupport/GRPCSendable.swift index d0f0906dc..f1c00d300 100644 --- a/Sources/GRPC/AsyncAwaitSupport/GRPCSendable.swift +++ b/Sources/GRPC/AsyncAwaitSupport/GRPCSendable.swift @@ -13,25 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - import NIOCore -#if compiler(>=5.6) +@available(*, deprecated, renamed: "Swift.Sendable") public typealias GRPCSendable = Swift.Sendable -#else -public typealias GRPCSendable = Any -#endif // compiler(>=5.6) -#if compiler(>=5.6) +@available(*, deprecated, message: "Use @preconcurrency Swift.Sendable") @preconcurrency public protocol GRPCPreconcurrencySendable: Sendable {} -#else -public protocol GRPCPreconcurrencySendable {} -#endif // compiler(>=5.6) -#if compiler(>=5.6) @preconcurrency public typealias GRPCChannelInitializer = @Sendable (Channel) -> EventLoopFuture -#else -public typealias GRPCChannelInitializer = (Channel) -> EventLoopFuture -#endif // compiler(>=5.6) diff --git a/Sources/GRPC/AsyncAwaitSupport/NIOAsyncWrappers.swift b/Sources/GRPC/AsyncAwaitSupport/NIOAsyncWrappers.swift index 40bffd123..9269d9b2f 100644 --- a/Sources/GRPC/AsyncAwaitSupport/NIOAsyncWrappers.swift +++ b/Sources/GRPC/AsyncAwaitSupport/NIOAsyncWrappers.swift @@ -13,8 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -#if compiler(>=5.6) import NIOCore /// Unchecked-sendable wrapper for ``NIOAsyncWriter/Sink``, to avoid getting sendability warnings. @@ -48,4 +46,3 @@ internal struct AsyncSink: @unchecked Sendable { self.sink.finish() } } -#endif // compiler(>=5.6) diff --git a/Sources/GRPC/CallOptions.swift b/Sources/GRPC/CallOptions.swift index 51631abd6..00bffb3cd 100644 --- a/Sources/GRPC/CallOptions.swift +++ b/Sources/GRPC/CallOptions.swift @@ -23,7 +23,7 @@ import NIOHTTP1 import NIOHTTP2 /// Options to use for GRPC calls. -public struct CallOptions: GRPCSendable { +public struct CallOptions: Sendable { /// Additional metadata to send to the service. public var customMetadata: HPACKHeaders @@ -125,14 +125,10 @@ public struct CallOptions: GRPCSendable { } extension CallOptions { - public struct RequestIDProvider: GRPCSendable { - #if swift(>=5.6) + public struct RequestIDProvider: Sendable { public typealias RequestIDGenerator = @Sendable () -> String - #else - public typealias RequestIDGenerator = () -> String - #endif // swift(>=5.6) - private enum RequestIDSource: GRPCSendable { + private enum RequestIDSource: Sendable { case none case `static`(String) case generated(RequestIDGenerator) @@ -179,7 +175,7 @@ extension CallOptions { } extension CallOptions { - public struct EventLoopPreference: GRPCSendable { + public struct EventLoopPreference: Sendable { /// No preference. The framework will assign an `EventLoop`. public static let indifferent = EventLoopPreference(.indifferent) @@ -189,7 +185,7 @@ extension CallOptions { } @usableFromInline - internal enum Preference: GRPCSendable { + internal enum Preference: Sendable { case indifferent case exact(EventLoop) } diff --git a/Sources/GRPC/ClientCalls/Call.swift b/Sources/GRPC/ClientCalls/Call.swift index 3277681a4..759798836 100644 --- a/Sources/GRPC/ClientCalls/Call.swift +++ b/Sources/GRPC/ClientCalls/Call.swift @@ -440,7 +440,5 @@ extension Call { } } -#if compiler(>=5.6) // @unchecked is ok: all mutable state is accessed/modified from the appropriate event loop. extension Call: @unchecked Sendable where Request: Sendable, Response: Sendable {} -#endif diff --git a/Sources/GRPC/ClientCalls/ResponseContainers.swift b/Sources/GRPC/ClientCalls/ResponseContainers.swift index 9169a8a5a..d8bf6411c 100644 --- a/Sources/GRPC/ClientCalls/ResponseContainers.swift +++ b/Sources/GRPC/ClientCalls/ResponseContainers.swift @@ -201,8 +201,6 @@ extension Error { } } -#if compiler(>=5.6) // @unchecked is ok: all mutable state is accessed/modified from an appropriate event loop. extension UnaryResponseParts: @unchecked Sendable where Response: Sendable {} extension StreamingResponseParts: @unchecked Sendable where Response: Sendable {} -#endif diff --git a/Sources/GRPC/ClientConnection.swift b/Sources/GRPC/ClientConnection.swift index bd04081d0..395c52978 100644 --- a/Sources/GRPC/ClientConnection.swift +++ b/Sources/GRPC/ClientConnection.swift @@ -13,11 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if swift(>=5.6) @preconcurrency import Foundation -#else -import Foundation -#endif // swift(>=5.6) import Logging import NIOCore @@ -83,7 +79,7 @@ import SwiftProtobuf /// The 'GRPCIdleHandler' intercepts HTTP/2 frames and various events and is responsible for /// informing and controlling the state of the connection (idling and keepalive). The HTTP/2 streams /// are used to handle individual RPCs. -public final class ClientConnection: GRPCSendable { +public final class ClientConnection: Sendable { private let connectionManager: ConnectionManager /// HTTP multiplexer from the underlying channel handling gRPC calls. @@ -266,7 +262,7 @@ extension ClientConnection: GRPCChannel { // MARK: - Configuration structures /// A target to connect to. -public struct ConnectionTarget: GRPCSendable { +public struct ConnectionTarget: Sendable { internal enum Wrapped { case hostAndPort(String, Int) case unixDomainSocket(String) @@ -320,8 +316,8 @@ public struct ConnectionTarget: GRPCSendable { } /// The connectivity behavior to use when starting an RPC. -public struct CallStartBehavior: Hashable, GRPCSendable { - internal enum Behavior: Hashable, GRPCSendable { +public struct CallStartBehavior: Hashable, Sendable { + internal enum Behavior: Hashable, Sendable { case waitsForConnectivity case fastFailure } @@ -354,7 +350,7 @@ public struct CallStartBehavior: Hashable, GRPCSendable { extension ClientConnection { /// Configuration for a ``ClientConnection``. Users should prefer using one of the /// ``ClientConnection`` builders: ``ClientConnection/secure(group:)`` or ``ClientConnection/insecure(group:)``. - public struct Configuration: GRPCSendable { + public struct Configuration: Sendable { /// The target to connect to. public var target: ConnectionTarget @@ -454,15 +450,10 @@ extension ClientConnection { /// used to add additional handlers to the pipeline and is intended for debugging. /// /// - Warning: The initializer closure may be invoked *multiple times*. - #if compiler(>=5.6) @preconcurrency public var debugChannelInitializer: (@Sendable (Channel) -> EventLoopFuture)? - #else - public var debugChannelInitializer: ((Channel) -> EventLoopFuture)? - #endif #if canImport(NIOSSL) - #if compiler(>=5.6) /// Create a `Configuration` with some pre-defined defaults. Prefer using /// `ClientConnection.secure(group:)` to build a connection secured with TLS or /// `ClientConnection.insecure(group:)` to build a plaintext connection. @@ -519,41 +510,6 @@ extension ClientConnection { self.backgroundActivityLogger = backgroundActivityLogger self.debugChannelInitializer = debugChannelInitializer } - #else - @available(*, deprecated, renamed: "default(target:eventLoopGroup:)") - public init( - target: ConnectionTarget, - eventLoopGroup: EventLoopGroup, - errorDelegate: ClientErrorDelegate? = LoggingClientErrorDelegate(), - connectivityStateDelegate: ConnectivityStateDelegate? = nil, - connectivityStateDelegateQueue: DispatchQueue? = nil, - tls: Configuration.TLS? = nil, - connectionBackoff: ConnectionBackoff? = ConnectionBackoff(), - connectionKeepalive: ClientConnectionKeepalive = ClientConnectionKeepalive(), - connectionIdleTimeout: TimeAmount = .minutes(30), - callStartBehavior: CallStartBehavior = .waitsForConnectivity, - httpTargetWindowSize: Int = 8 * 1024 * 1024, - backgroundActivityLogger: Logger = Logger( - label: "io.grpc", - factory: { _ in SwiftLogNoOpLogHandler() } - ), - debugChannelInitializer: ((Channel) -> EventLoopFuture)? = nil - ) { - self.target = target - self.eventLoopGroup = eventLoopGroup - self.errorDelegate = errorDelegate - self.connectivityStateDelegate = connectivityStateDelegate - self.connectivityStateDelegateQueue = connectivityStateDelegateQueue - self.tlsConfiguration = tls.map { GRPCTLSConfiguration(transforming: $0) } - self.connectionBackoff = connectionBackoff - self.connectionKeepalive = connectionKeepalive - self.connectionIdleTimeout = connectionIdleTimeout - self.callStartBehavior = callStartBehavior - self.httpTargetWindowSize = httpTargetWindowSize - self.backgroundActivityLogger = backgroundActivityLogger - self.debugChannelInitializer = debugChannelInitializer - } - #endif // compiler(>=5.6) #endif // canImport(NIOSSL) private init(eventLoopGroup: EventLoopGroup, target: ConnectionTarget) { diff --git a/Sources/GRPC/ClientErrorDelegate.swift b/Sources/GRPC/ClientErrorDelegate.swift index ee3734ae2..93119a7cb 100644 --- a/Sources/GRPC/ClientErrorDelegate.swift +++ b/Sources/GRPC/ClientErrorDelegate.swift @@ -22,7 +22,8 @@ import Logging /// The intended use of this protocol is with ``ClientConnection``. In order to avoid retain /// cycles, classes implementing this delegate **must not** maintain a strong reference to the /// ``ClientConnection``. -public protocol ClientErrorDelegate: AnyObject, GRPCPreconcurrencySendable { +@preconcurrency +public protocol ClientErrorDelegate: AnyObject, Sendable { /// Called when the client catches an error. /// /// - Parameters: diff --git a/Sources/GRPC/Compression/CompressionAlgorithm.swift b/Sources/GRPC/Compression/CompressionAlgorithm.swift index 2b7a56592..960cf7d9b 100644 --- a/Sources/GRPC/Compression/CompressionAlgorithm.swift +++ b/Sources/GRPC/Compression/CompressionAlgorithm.swift @@ -18,7 +18,7 @@ /// /// These algorithms are indicated in the "grpc-encoding" header. As such, a lack of "grpc-encoding" /// header indicates that there is no message compression. -public struct CompressionAlgorithm: Equatable, GRPCSendable { +public struct CompressionAlgorithm: Equatable, Sendable { /// Identity compression; "no" compression but indicated via the "grpc-encoding" header. public static let identity = CompressionAlgorithm(.identity) public static let deflate = CompressionAlgorithm(.deflate) diff --git a/Sources/GRPC/Compression/DecompressionLimit.swift b/Sources/GRPC/Compression/DecompressionLimit.swift index b206e7e1a..6f002ed6f 100644 --- a/Sources/GRPC/Compression/DecompressionLimit.swift +++ b/Sources/GRPC/Compression/DecompressionLimit.swift @@ -14,8 +14,8 @@ * limitations under the License. */ -public struct DecompressionLimit: Equatable, GRPCSendable { - private enum Limit: Equatable, GRPCSendable { +public struct DecompressionLimit: Equatable, Sendable { + private enum Limit: Equatable, Sendable { case ratio(Int) case absolute(Int) } diff --git a/Sources/GRPC/Compression/MessageEncoding.swift b/Sources/GRPC/Compression/MessageEncoding.swift index 60605768e..6301c12bb 100644 --- a/Sources/GRPC/Compression/MessageEncoding.swift +++ b/Sources/GRPC/Compression/MessageEncoding.swift @@ -15,9 +15,9 @@ */ /// Whether compression should be enabled for the message. -public struct Compression: Hashable, GRPCSendable { +public struct Compression: Hashable, Sendable { @usableFromInline - internal enum _Wrapped: Hashable, GRPCSendable { + internal enum _Wrapped: Hashable, Sendable { case enabled case disabled case deferToCallDefault @@ -57,7 +57,7 @@ extension Compression { } /// Whether compression is enabled or disabled for a client. -public enum ClientMessageEncoding: GRPCSendable { +public enum ClientMessageEncoding: Sendable { /// Compression is enabled with the given configuration. case enabled(Configuration) /// Compression is disabled. @@ -76,7 +76,7 @@ extension ClientMessageEncoding { } extension ClientMessageEncoding { - public struct Configuration: GRPCSendable { + public struct Configuration: Sendable { public init( forRequests outbound: CompressionAlgorithm?, acceptableForResponses inbound: [CompressionAlgorithm] = CompressionAlgorithm.all, diff --git a/Sources/GRPC/ConnectionBackoff.swift b/Sources/GRPC/ConnectionBackoff.swift index c176757de..561fc23c6 100644 --- a/Sources/GRPC/ConnectionBackoff.swift +++ b/Sources/GRPC/ConnectionBackoff.swift @@ -19,7 +19,7 @@ import Foundation /// /// This algorithm and defaults are determined by the gRPC connection backoff /// [documentation](https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md). -public struct ConnectionBackoff: Sequence, GRPCSendable { +public struct ConnectionBackoff: Sequence, Sendable { public typealias Iterator = ConnectionBackoffIterator /// The initial backoff in seconds. @@ -41,8 +41,8 @@ public struct ConnectionBackoff: Sequence, GRPCSendable { /// A limit on the number of times to attempt reconnection. public var retries: Retries - public struct Retries: Hashable, GRPCSendable { - fileprivate enum Limit: Hashable, GRPCSendable { + public struct Retries: Hashable, Sendable { + fileprivate enum Limit: Hashable, Sendable { case limited(Int) case unlimited } diff --git a/Sources/GRPC/ConnectionKeepalive.swift b/Sources/GRPC/ConnectionKeepalive.swift index 8035cd5d6..841081f81 100644 --- a/Sources/GRPC/ConnectionKeepalive.swift +++ b/Sources/GRPC/ConnectionKeepalive.swift @@ -19,7 +19,7 @@ import NIOCore /// /// The defaults are determined by the gRPC keepalive /// [documentation] (https://github.com/grpc/grpc/blob/master/doc/keepalive.md). -public struct ClientConnectionKeepalive: Hashable, GRPCSendable { +public struct ClientConnectionKeepalive: Hashable, Sendable { /// The amount of time to wait before sending a keepalive ping. public var interval: TimeAmount diff --git a/Sources/GRPC/ConnectionManager+Delegates.swift b/Sources/GRPC/ConnectionManager+Delegates.swift index 35d5a870e..5b214f57e 100644 --- a/Sources/GRPC/ConnectionManager+Delegates.swift +++ b/Sources/GRPC/ConnectionManager+Delegates.swift @@ -60,7 +60,7 @@ internal protocol ConnectionManagerHTTP2Delegate { // This mirrors `ConnectivityState` (which is public API) but adds `Error` as associated data // to a few cases. -internal enum _ConnectivityState: GRPCSendable { +internal enum _ConnectivityState: Sendable { case idle(Error?) case connecting case ready diff --git a/Sources/GRPC/ConnectionManager.swift b/Sources/GRPC/ConnectionManager.swift index 8b66f505e..35ee41101 100644 --- a/Sources/GRPC/ConnectionManager.swift +++ b/Sources/GRPC/ConnectionManager.swift @@ -19,16 +19,12 @@ import NIOConcurrencyHelpers import NIOCore import NIOHTTP2 -#if compiler(>=5.6) // Unchecked because mutable state is always accessed and modified on a particular event loop. // APIs which _may_ be called from different threads execute onto the correct event loop first. // APIs which _must_ be called from an exact event loop have preconditions checking that the correct // event loop is being used. -extension ConnectionManager: @unchecked Sendable {} -#endif // compiler(>=5.6) - @usableFromInline -internal final class ConnectionManager { +internal final class ConnectionManager: @unchecked Sendable { internal enum Reconnect { case none case after(TimeInterval) diff --git a/Sources/GRPC/ConnectionPool/ConnectionManagerID.swift b/Sources/GRPC/ConnectionPool/ConnectionManagerID.swift index 15f87a0e9..33a7220ed 100644 --- a/Sources/GRPC/ConnectionPool/ConnectionManagerID.swift +++ b/Sources/GRPC/ConnectionPool/ConnectionManagerID.swift @@ -15,7 +15,7 @@ */ @usableFromInline -internal struct ConnectionManagerID: Hashable, CustomStringConvertible, GRPCSendable { +internal struct ConnectionManagerID: Hashable, CustomStringConvertible, Sendable { @usableFromInline internal let _id: ObjectIdentifier diff --git a/Sources/GRPC/ConnectionPool/GRPCChannelPool.swift b/Sources/GRPC/ConnectionPool/GRPCChannelPool.swift index ea7a23c53..6011d071d 100644 --- a/Sources/GRPC/ConnectionPool/GRPCChannelPool.swift +++ b/Sources/GRPC/ConnectionPool/GRPCChannelPool.swift @@ -87,7 +87,7 @@ public enum GRPCChannelPool { } extension GRPCChannelPool { - public struct Configuration: GRPCSendable { + public struct Configuration: Sendable { @inlinable internal init( target: ConnectionTarget, @@ -167,12 +167,8 @@ extension GRPCChannelPool { /// This may be used to add additional handlers to the pipeline and is intended for debugging. /// /// - Warning: The initializer closure may be invoked *multiple times*. - #if compiler(>=5.6) @preconcurrency public var debugChannelInitializer: (@Sendable (Channel) -> EventLoopFuture)? - #else - public var debugChannelInitializer: ((Channel) -> EventLoopFuture)? - #endif /// An error delegate which is called when errors are caught. public var errorDelegate: ClientErrorDelegate? @@ -192,7 +188,7 @@ extension GRPCChannelPool { } extension GRPCChannelPool.Configuration { - public struct TransportSecurity: GRPCSendable { + public struct TransportSecurity: Sendable { private init(_ configuration: GRPCTLSConfiguration?) { self.tlsConfiguration = configuration } @@ -219,7 +215,7 @@ extension GRPCChannelPool.Configuration { } extension GRPCChannelPool.Configuration { - public struct HTTP2: Hashable, GRPCSendable { + public struct HTTP2: Hashable, Sendable { private static let allowedTargetWindowSizes = (1 ... Int(Int32.max)) private static let allowedMaxFrameSizes = (1 << 14) ... ((1 << 24) - 1) @@ -252,7 +248,7 @@ extension GRPCChannelPool.Configuration { } extension GRPCChannelPool.Configuration { - public struct ConnectionPool: Hashable, GRPCSendable { + public struct ConnectionPool: Hashable, Sendable { /// Default connection pool configuration. public static let defaults = ConnectionPool() @@ -293,7 +289,7 @@ extension GRPCChannelPool.Configuration { } /// The ID of a connection in the connection pool. -public struct GRPCConnectionID: Hashable, GRPCSendable, CustomStringConvertible { +public struct GRPCConnectionID: Hashable, Sendable, CustomStringConvertible { private let id: ConnectionManagerID public var description: String { @@ -309,7 +305,7 @@ public struct GRPCConnectionID: Hashable, GRPCSendable, CustomStringConvertible /// /// All functions must execute quickly and may be executed on arbitrary threads. The implementor is /// responsible for ensuring thread safety. -public protocol GRPCConnectionPoolDelegate: GRPCSendable { +public protocol GRPCConnectionPoolDelegate: Sendable { /// A new connection was created with the given ID and added to the pool. The connection is not /// yet active (or connecting). /// diff --git a/Sources/GRPC/ConnectionPool/PoolManager.swift b/Sources/GRPC/ConnectionPool/PoolManager.swift index 05bd33641..c9f745422 100644 --- a/Sources/GRPC/ConnectionPool/PoolManager.swift +++ b/Sources/GRPC/ConnectionPool/PoolManager.swift @@ -17,10 +17,8 @@ import Logging import NIOConcurrencyHelpers import NIOCore -#if compiler(>=5.6) // Unchecked because all mutable state is protected by a lock. extension PooledChannel: @unchecked Sendable {} -#endif // compiler(>=5.6) @usableFromInline internal final class PoolManager { diff --git a/Sources/GRPC/ConnectivityState.swift b/Sources/GRPC/ConnectivityState.swift index 9b46da131..3ab871d46 100644 --- a/Sources/GRPC/ConnectivityState.swift +++ b/Sources/GRPC/ConnectivityState.swift @@ -20,7 +20,7 @@ import NIOCore /// The connectivity state of a client connection. Note that this is heavily lifted from the gRPC /// documentation: https://github.com/grpc/grpc/blob/master/doc/connectivity-semantics-and-api.md. -public enum ConnectivityState: GRPCSendable { +public enum ConnectivityState: Sendable { /// This is the state where the channel has not yet been created. case idle @@ -47,7 +47,8 @@ public enum ConnectivityState: GRPCSendable { case shutdown } -public protocol ConnectivityStateDelegate: AnyObject, GRPCPreconcurrencySendable { +@preconcurrency +public protocol ConnectivityStateDelegate: AnyObject, Sendable { /// Called when a change in ``ConnectivityState`` has occurred. /// /// - Parameter oldState: The old connectivity state. @@ -68,12 +69,8 @@ extension ConnectivityStateDelegate { public func connectionStartedQuiescing() {} } -#if compiler(>=5.6) // Unchecked because all mutable state is protected by locks. -extension ConnectivityStateMonitor: @unchecked Sendable {} -#endif // compiler(>=5.6) - -public class ConnectivityStateMonitor { +public class ConnectivityStateMonitor: @unchecked Sendable { private let stateLock = NIOLock() private var _state: ConnectivityState = .idle diff --git a/Sources/GRPC/Docs.docc/index.md b/Sources/GRPC/Docs.docc/index.md index 1a58334c0..d5ef1a85f 100644 --- a/Sources/GRPC/Docs.docc/index.md +++ b/Sources/GRPC/Docs.docc/index.md @@ -26,7 +26,8 @@ gRPC Swift Version | Earliest Swift Version -------------------|----------------------- `1.0.0 ..< 1.8.0` | 5.2 `1.8.0 ..< 1.11.0` | 5.4 -`1.11.0...` | 5.5 +`1.11.0..< 1.16.0`.| 5.5 +`1.16.0...` | 5.6 Versions of clients and services which are use Swift's Concurrency support are available from gRPC Swift 1.8.0 and require Swift 5.6 and newer. @@ -42,7 +43,7 @@ package dependency to your `Package.swift`: ```swift dependencies: [ - .package(url: "https://github.com/grpc/grpc-swift.git", from: "1.9.0") + .package(url: "https://github.com/grpc/grpc-swift.git", from: "1.15.0") ] ``` diff --git a/Sources/GRPC/FakeChannel.swift b/Sources/GRPC/FakeChannel.swift index 46ce88be8..8348b215f 100644 --- a/Sources/GRPC/FakeChannel.swift +++ b/Sources/GRPC/FakeChannel.swift @@ -18,11 +18,9 @@ import NIOCore import NIOEmbedded import SwiftProtobuf -#if compiler(>=5.6) // This type is deprecated, but we need to '@unchecked Sendable' to avoid warnings in our own code. @available(swift, deprecated: 5.6) extension FakeChannel: @unchecked Sendable {} -#endif // compiler(>=5.6) /// A fake channel for use with generated test clients. /// diff --git a/Sources/GRPC/GRPCChannel/GRPCChannel.swift b/Sources/GRPC/GRPCChannel/GRPCChannel.swift index b34ef5c12..2e045d069 100644 --- a/Sources/GRPC/GRPCChannel/GRPCChannel.swift +++ b/Sources/GRPC/GRPCChannel/GRPCChannel.swift @@ -17,7 +17,8 @@ import NIOCore import NIOHTTP2 import SwiftProtobuf -public protocol GRPCChannel: GRPCPreconcurrencySendable { +@preconcurrency +public protocol GRPCChannel: Sendable { /// Makes a gRPC call on the channel with requests and responses conforming to /// `SwiftProtobuf.Message`. /// diff --git a/Sources/GRPC/GRPCChannel/GRPCChannelBuilder.swift b/Sources/GRPC/GRPCChannel/GRPCChannelBuilder.swift index a726e46e0..67ea2619b 100644 --- a/Sources/GRPC/GRPCChannel/GRPCChannelBuilder.swift +++ b/Sources/GRPC/GRPCChannel/GRPCChannelBuilder.swift @@ -315,7 +315,6 @@ extension ClientConnection.Builder { /// used to add additional handlers to the pipeline and is intended for debugging. /// /// - Warning: The initializer closure may be invoked *multiple times*. - #if compiler(>=5.6) @discardableResult @preconcurrency public func withDebugChannelInitializer( @@ -324,15 +323,6 @@ extension ClientConnection.Builder { self.configuration.debugChannelInitializer = debugChannelInitializer return self } - #else - @discardableResult - public func withDebugChannelInitializer( - _ debugChannelInitializer: @escaping (Channel) -> EventLoopFuture - ) -> Self { - self.configuration.debugChannelInitializer = debugChannelInitializer - return self - } - #endif } extension Double { diff --git a/Sources/GRPC/GRPCClient.swift b/Sources/GRPC/GRPCClient.swift index 1a892c46e..92e09ff9c 100644 --- a/Sources/GRPC/GRPCClient.swift +++ b/Sources/GRPC/GRPCClient.swift @@ -19,7 +19,8 @@ import NIOHTTP2 import SwiftProtobuf /// A gRPC client. -public protocol GRPCClient: GRPCPreconcurrencySendable { +@preconcurrency +public protocol GRPCClient: Sendable { /// The gRPC channel over which RPCs are sent and received. Note that this is distinct /// from `NIO.Channel`. var channel: GRPCChannel { get } @@ -202,11 +203,9 @@ public final class AnyServiceClient: GRPCClient { } } -#if swift(>=5.6) // Unchecked because mutable state is protected by a lock. @available(*, deprecated, renamed: "GRPCAnyServiceClient") -extension AnyServiceClient: @unchecked GRPCSendable {} -#endif // swift(>=5.6) +extension AnyServiceClient: @unchecked Sendable {} /// A client which has no generated stubs and may be used to create gRPC calls manually. /// See ``GRPCClient`` for details. diff --git a/Sources/GRPC/GRPCClientChannelHandler.swift b/Sources/GRPC/GRPCClientChannelHandler.swift index d8bb8d999..3464ef1c2 100644 --- a/Sources/GRPC/GRPCClientChannelHandler.swift +++ b/Sources/GRPC/GRPCClientChannelHandler.swift @@ -226,7 +226,7 @@ extension _GRPCRequestHead { } /// The type of gRPC call. -public enum GRPCCallType: Hashable, GRPCSendable { +public enum GRPCCallType: Hashable, Sendable { /// Unary: a single request and a single response. case unary diff --git a/Sources/GRPC/GRPCServiceDescription.swift b/Sources/GRPC/GRPCServiceDescription.swift index cfa5cc427..7b88905c3 100644 --- a/Sources/GRPC/GRPCServiceDescription.swift +++ b/Sources/GRPC/GRPCServiceDescription.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -public struct GRPCServiceDescriptor: Hashable, GRPCSendable { +public struct GRPCServiceDescriptor: Hashable, Sendable { /// The name of the service excluding the package, e.g. 'Echo'. public var name: String @@ -31,7 +31,7 @@ public struct GRPCServiceDescriptor: Hashable, GRPCSendable { } } -public struct GRPCMethodDescriptor: Hashable, GRPCSendable { +public struct GRPCMethodDescriptor: Hashable, Sendable { /// The name of the method, e.g. 'Get'. public var name: String diff --git a/Sources/GRPC/GRPCStatus.swift b/Sources/GRPC/GRPCStatus.swift index 16290041f..3087dfd0e 100644 --- a/Sources/GRPC/GRPCStatus.swift +++ b/Sources/GRPC/GRPCStatus.swift @@ -18,7 +18,7 @@ import NIOHTTP1 import NIOHTTP2 /// Encapsulates the result of a gRPC call. -public struct GRPCStatus: Error, GRPCSendable { +public struct GRPCStatus: Error, Sendable { /// Storage for message/cause. In the happy case ('ok') there will not be a message or cause /// and this will reference a static storage containing nil values. Making it optional makes the /// setters for message and cause a little messy. @@ -145,7 +145,7 @@ extension GRPCStatus { extension GRPCStatus { /// Status codes for gRPC operations (replicated from `status_code_enum.h` in the /// [gRPC core library](https://github.com/grpc/grpc)). - public struct Code: Hashable, CustomStringConvertible, GRPCSendable { + public struct Code: Hashable, CustomStringConvertible, Sendable { // `rawValue` must be an `Int` for API reasons and we don't need (or want) to store anything so // wide, a `UInt8` is fine. private let _rawValue: UInt8 @@ -316,11 +316,9 @@ extension GRPCStatus { } } -#if compiler(>=5.6) // `GRPCStatus` has CoW semantics so it is inherently `Sendable`. Rather than marking `GRPCStatus` // as `@unchecked Sendable` we only mark `Storage` as such. extension GRPCStatus.Storage: @unchecked Sendable {} -#endif // compiler(>=5.6) /// This protocol serves as a customisation point for error types so that gRPC calls may be /// terminated with an appropriate status. diff --git a/Sources/GRPC/GRPCTLSConfiguration.swift b/Sources/GRPC/GRPCTLSConfiguration.swift index cf3a9f2dd..8adc7ad50 100644 --- a/Sources/GRPC/GRPCTLSConfiguration.swift +++ b/Sources/GRPC/GRPCTLSConfiguration.swift @@ -28,8 +28,8 @@ import Security /// This structure allow configuring TLS for a wide range of TLS implementations. Some /// options are removed from the user's control to ensure the configuration complies with /// the gRPC specification. -public struct GRPCTLSConfiguration: GRPCSendable { - fileprivate enum Backend: GRPCSendable { +public struct GRPCTLSConfiguration: Sendable { + fileprivate enum Backend: Sendable { #if canImport(NIOSSL) /// Configuration for NIOSSSL. case nio(NIOConfiguration) diff --git a/Sources/GRPC/Interceptor/ClientInterceptors.swift b/Sources/GRPC/Interceptor/ClientInterceptors.swift index 282549d5a..74d567567 100644 --- a/Sources/GRPC/Interceptor/ClientInterceptors.swift +++ b/Sources/GRPC/Interceptor/ClientInterceptors.swift @@ -48,7 +48,6 @@ import NIOCore /// require any extra attention. However, if work is done on a `DispatchQueue` or _other_ /// `EventLoop` then implementers should ensure that they use `context` from the correct /// `EventLoop`. -#if swift(>=5.6) @preconcurrency open class ClientInterceptor: @unchecked Sendable { public init() {} @@ -98,54 +97,3 @@ import NIOCore context.cancel(promise: promise) } } -#else -open class ClientInterceptor { - public init() {} - - /// Called when the interceptor has received a response part to handle. - /// - Parameters: - /// - part: The response part which has been received from the server. - /// - context: An interceptor context which may be used to forward the response part. - open func receive( - _ part: GRPCClientResponsePart, - context: ClientInterceptorContext - ) { - context.receive(part) - } - - /// Called when the interceptor has received an error. - /// - Parameters: - /// - error: The error. - /// - context: An interceptor context which may be used to forward the error. - open func errorCaught( - _ error: Error, - context: ClientInterceptorContext - ) { - context.errorCaught(error) - } - - /// Called when the interceptor has received a request part to handle. - /// - Parameters: - /// - part: The request part which should be sent to the server. - /// - promise: A promise which should be completed when the response part has been handled. - /// - context: An interceptor context which may be used to forward the request part. - open func send( - _ part: GRPCClientRequestPart, - promise: EventLoopPromise?, - context: ClientInterceptorContext - ) { - context.send(part, promise: promise) - } - - /// Called when the interceptor has received a request to cancel the RPC. - /// - Parameters: - /// - promise: A promise which should be cancellation request has been handled. - /// - context: An interceptor context which may be used to forward the cancellation request. - open func cancel( - promise: EventLoopPromise?, - context: ClientInterceptorContext - ) { - context.cancel(promise: promise) - } -} -#endif // swift(>=5.6) diff --git a/Sources/GRPC/Interceptor/MessageParts.swift b/Sources/GRPC/Interceptor/MessageParts.swift index 9d81bc321..1e2495884 100644 --- a/Sources/GRPC/Interceptor/MessageParts.swift +++ b/Sources/GRPC/Interceptor/MessageParts.swift @@ -60,7 +60,7 @@ public enum GRPCServerResponsePart { } /// Metadata associated with a request or response message. -public struct MessageMetadata: Equatable, GRPCSendable { +public struct MessageMetadata: Equatable, Sendable { /// Whether the message should be compressed. If compression has not been enabled on the RPC /// then this setting is ignored. public var compress: Bool @@ -100,9 +100,7 @@ extension GRPCServerResponsePart { } } -#if swift(>=5.6) extension GRPCClientRequestPart: Sendable where Request: Sendable {} extension GRPCClientResponsePart: Sendable where Response: Sendable {} extension GRPCServerRequestPart: Sendable where Request: Sendable {} extension GRPCServerResponsePart: Sendable where Response: Sendable {} -#endif diff --git a/Sources/GRPC/TimeLimit.swift b/Sources/GRPC/TimeLimit.swift index ab370f240..7ea6e1de1 100644 --- a/Sources/GRPC/TimeLimit.swift +++ b/Sources/GRPC/TimeLimit.swift @@ -24,9 +24,9 @@ import NIOCore /// /// - Note: Servers may impose a time limit on an RPC independent of the client's time limit; RPCs /// may therefore complete with ``GRPCStatus/Code-swift.struct/deadlineExceeded`` even if no time limit was set by the client. -public struct TimeLimit: Equatable, CustomStringConvertible, GRPCSendable { +public struct TimeLimit: Equatable, CustomStringConvertible, Sendable { // private but for shimming. - private enum Wrapped: Equatable, GRPCSendable { + private enum Wrapped: Equatable, Sendable { case none case timeout(TimeAmount) case deadline(NIODeadline) diff --git a/Sources/GRPCInteroperabilityTestModels/Generated/test.grpc.swift b/Sources/GRPCInteroperabilityTestModels/Generated/test.grpc.swift index 90ebf84d9..230bd1692 100644 --- a/Sources/GRPCInteroperabilityTestModels/Generated/test.grpc.swift +++ b/Sources/GRPCInteroperabilityTestModels/Generated/test.grpc.swift @@ -244,10 +244,8 @@ extension Grpc_Testing_TestServiceClientProtocol { } } -#if compiler(>=5.6) @available(*, deprecated) extension Grpc_Testing_TestServiceClient: @unchecked Sendable {} -#endif // compiler(>=5.6) @available(*, deprecated, renamed: "Grpc_Testing_TestServiceNIOClient") public final class Grpc_Testing_TestServiceClient: Grpc_Testing_TestServiceClientProtocol { @@ -303,7 +301,6 @@ public struct Grpc_Testing_TestServiceNIOClient: Grpc_Testing_TestServiceClientP } } -#if compiler(>=5.6) /// A simple service to test the various types of RPCs and experiment with /// performance with various types of payload. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) @@ -602,9 +599,7 @@ public struct Grpc_Testing_TestServiceAsyncClient: Grpc_Testing_TestServiceAsync } } -#endif // compiler(>=5.6) - -public protocol Grpc_Testing_TestServiceClientInterceptorFactoryProtocol: GRPCSendable { +public protocol Grpc_Testing_TestServiceClientInterceptorFactoryProtocol: Sendable { /// - Returns: Interceptors to use when invoking 'emptyCall'. func makeEmptyCallInterceptors() -> [ClientInterceptor] @@ -736,10 +731,8 @@ extension Grpc_Testing_UnimplementedServiceClientProtocol { } } -#if compiler(>=5.6) @available(*, deprecated) extension Grpc_Testing_UnimplementedServiceClient: @unchecked Sendable {} -#endif // compiler(>=5.6) @available(*, deprecated, renamed: "Grpc_Testing_UnimplementedServiceNIOClient") public final class Grpc_Testing_UnimplementedServiceClient: Grpc_Testing_UnimplementedServiceClientProtocol { @@ -795,7 +788,6 @@ public struct Grpc_Testing_UnimplementedServiceNIOClient: Grpc_Testing_Unimpleme } } -#if compiler(>=5.6) /// A simple service NOT implemented at servers so clients can test for /// that case. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) @@ -864,9 +856,7 @@ public struct Grpc_Testing_UnimplementedServiceAsyncClient: Grpc_Testing_Unimple } } -#endif // compiler(>=5.6) - -public protocol Grpc_Testing_UnimplementedServiceClientInterceptorFactoryProtocol: GRPCSendable { +public protocol Grpc_Testing_UnimplementedServiceClientInterceptorFactoryProtocol: Sendable { /// - Returns: Interceptors to use when invoking 'unimplementedCall'. func makeUnimplementedCallInterceptors() -> [ClientInterceptor] @@ -950,10 +940,8 @@ extension Grpc_Testing_ReconnectServiceClientProtocol { } } -#if compiler(>=5.6) @available(*, deprecated) extension Grpc_Testing_ReconnectServiceClient: @unchecked Sendable {} -#endif // compiler(>=5.6) @available(*, deprecated, renamed: "Grpc_Testing_ReconnectServiceNIOClient") public final class Grpc_Testing_ReconnectServiceClient: Grpc_Testing_ReconnectServiceClientProtocol { @@ -1009,7 +997,6 @@ public struct Grpc_Testing_ReconnectServiceNIOClient: Grpc_Testing_ReconnectServ } } -#if compiler(>=5.6) /// A service used to control reconnect server. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public protocol Grpc_Testing_ReconnectServiceAsyncClientProtocol: GRPCClient { @@ -1106,9 +1093,7 @@ public struct Grpc_Testing_ReconnectServiceAsyncClient: Grpc_Testing_ReconnectSe } } -#endif // compiler(>=5.6) - -public protocol Grpc_Testing_ReconnectServiceClientInterceptorFactoryProtocol: GRPCSendable { +public protocol Grpc_Testing_ReconnectServiceClientInterceptorFactoryProtocol: Sendable { /// - Returns: Interceptors to use when invoking 'start'. func makeStartInterceptors() -> [ClientInterceptor] @@ -1261,8 +1246,6 @@ extension Grpc_Testing_TestServiceProvider { } } -#if compiler(>=5.6) - /// A simple service to test the various types of RPCs and experiment with /// performance with various types of payload. /// @@ -1415,8 +1398,6 @@ extension Grpc_Testing_TestServiceAsyncProvider { } } -#endif // compiler(>=5.6) - public protocol Grpc_Testing_TestServiceServerInterceptorFactoryProtocol { /// - Returns: Interceptors to use when handling 'emptyCall'. @@ -1556,8 +1537,6 @@ extension Grpc_Testing_UnimplementedServiceProvider { } } -#if compiler(>=5.6) - /// A simple service NOT implemented at servers so clients can test for /// that case. /// @@ -1608,8 +1587,6 @@ extension Grpc_Testing_UnimplementedServiceAsyncProvider { } } -#endif // compiler(>=5.6) - public protocol Grpc_Testing_UnimplementedServiceServerInterceptorFactoryProtocol { /// - Returns: Interceptors to use when handling 'unimplementedCall'. @@ -1681,8 +1658,6 @@ extension Grpc_Testing_ReconnectServiceProvider { } } -#if compiler(>=5.6) - /// A service used to control reconnect server. /// /// To implement a server, implement an object which conforms to this protocol. @@ -1745,8 +1720,6 @@ extension Grpc_Testing_ReconnectServiceAsyncProvider { } } -#endif // compiler(>=5.6) - public protocol Grpc_Testing_ReconnectServiceServerInterceptorFactoryProtocol { /// - Returns: Interceptors to use when handling 'start'. diff --git a/Sources/GRPCInteroperabilityTestsImplementation/TestServiceAsyncProvider.swift b/Sources/GRPCInteroperabilityTestsImplementation/TestServiceAsyncProvider.swift index 689287dc4..9427b6e58 100644 --- a/Sources/GRPCInteroperabilityTestsImplementation/TestServiceAsyncProvider.swift +++ b/Sources/GRPCInteroperabilityTestsImplementation/TestServiceAsyncProvider.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import Foundation import GRPC import GRPCInteroperabilityTestModels @@ -217,4 +216,3 @@ public class TestServiceAsyncProvider: Grpc_Testing_TestServiceAsyncProvider { ) } } -#endif // compiler(>=5.6) diff --git a/Sources/protoc-gen-grpc-swift/Generator-Client.swift b/Sources/protoc-gen-grpc-swift/Generator-Client.swift index be2157549..c093cc9ae 100644 --- a/Sources/protoc-gen-grpc-swift/Generator-Client.swift +++ b/Sources/protoc-gen-grpc-swift/Generator-Client.swift @@ -29,7 +29,6 @@ extension Generator { self.println() self.printStructBackedServiceClientImplementation() self.println() - self.printIfCompilerGuardForAsyncAwait() self.printAsyncServiceClientProtocol() self.println() self.printAsyncClientProtocolExtension() @@ -38,8 +37,6 @@ extension Generator { self.println() self.printAsyncServiceClientImplementation() self.println() - self.printEndCompilerGuardForAsyncAwait() - self.println() // Both implementations share definitions for interceptors and metadata. self.printServiceClientInterceptorFactoryProtocol() self.println() @@ -159,7 +156,7 @@ extension Generator { } private func printServiceClientInterceptorFactoryProtocol() { - self.println("\(self.access) protocol \(self.clientInterceptorProtocolName): GRPCSendable {") + self.println("\(self.access) protocol \(self.clientInterceptorProtocolName): Sendable {") self.withIndentation { // Method specific interceptors. for method in service.methods { @@ -189,10 +186,8 @@ extension Generator { } private func printClassBackedServiceClientImplementation() { - self.printIfCompilerGuardForAsyncAwait() self.println("@available(*, deprecated)") self.println("extension \(clientClassName): @unchecked Sendable {}") - self.printEndCompilerGuardForAsyncAwait() self.println() self.println("@available(*, deprecated, renamed: \"\(clientStructName)\")") println("\(access) final class \(clientClassName): \(clientProtocolName) {") @@ -534,10 +529,8 @@ extension Generator { } private func printTestClient() { - self.printIfCompilerGuardForAsyncAwait() self.println("@available(swift, deprecated: 5.6)") self.println("extension \(self.testClientClassName): @unchecked Sendable {}") - self.printEndCompilerGuardForAsyncAwait() self.println() self.println( "@available(swift, deprecated: 5.6, message: \"Test clients are not Sendable " diff --git a/Sources/protoc-gen-grpc-swift/Generator-Server.swift b/Sources/protoc-gen-grpc-swift/Generator-Server.swift index 780e6c98a..4a483fb01 100644 --- a/Sources/protoc-gen-grpc-swift/Generator-Server.swift +++ b/Sources/protoc-gen-grpc-swift/Generator-Server.swift @@ -24,14 +24,10 @@ extension Generator { self.println() self.printServerProtocolExtension() self.println() - self.printIfCompilerGuardForAsyncAwait() - self.println() self.printServerProtocolAsyncAwait() self.println() self.printServerProtocolExtensionAsyncAwait() self.println() - self.printEndCompilerGuardForAsyncAwait() - self.println() // Both implementations share definitions for interceptors and metadata. self.printServerInterceptorFactoryProtocol() self.println() diff --git a/Sources/protoc-gen-grpc-swift/Generator.swift b/Sources/protoc-gen-grpc-swift/Generator.swift index a85101899..76589a2f6 100644 --- a/Sources/protoc-gen-grpc-swift/Generator.swift +++ b/Sources/protoc-gen-grpc-swift/Generator.swift @@ -169,12 +169,4 @@ class Generator { func printAvailabilityForAsyncAwait() { self.println("@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)") } - - func printIfCompilerGuardForAsyncAwait() { - self.println("#if compiler(>=5.6)") - } - - func printEndCompilerGuardForAsyncAwait() { - self.println("#endif // compiler(>=5.6)") - } } diff --git a/Tests/GRPCTests/AsyncAwaitSupport/AsyncClientTests.swift b/Tests/GRPCTests/AsyncAwaitSupport/AsyncClientTests.swift index df009a6cf..1d8697b7e 100644 --- a/Tests/GRPCTests/AsyncAwaitSupport/AsyncClientTests.swift +++ b/Tests/GRPCTests/AsyncAwaitSupport/AsyncClientTests.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import EchoImplementation import EchoModel import GRPC @@ -416,5 +415,3 @@ final class AsyncClientCancellationTests: GRPCTestCase { } } } - -#endif // compiler(>=5.6) diff --git a/Tests/GRPCTests/AsyncAwaitSupport/AsyncIntegrationTests.swift b/Tests/GRPCTests/AsyncAwaitSupport/AsyncIntegrationTests.swift index 4f41ebef0..de8e8670c 100644 --- a/Tests/GRPCTests/AsyncAwaitSupport/AsyncIntegrationTests.swift +++ b/Tests/GRPCTests/AsyncAwaitSupport/AsyncIntegrationTests.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import EchoImplementation import EchoModel import GRPC @@ -195,5 +194,3 @@ extension HPACKHeaders { XCTAssertEqual(self.first(name: name), value) } } - -#endif // compiler(>=5.6) diff --git a/Tests/GRPCTests/AsyncAwaitSupport/AsyncSequence+Helpers.swift b/Tests/GRPCTests/AsyncAwaitSupport/AsyncSequence+Helpers.swift index 89e16169c..cadad82ce 100644 --- a/Tests/GRPCTests/AsyncAwaitSupport/AsyncSequence+Helpers.swift +++ b/Tests/GRPCTests/AsyncAwaitSupport/AsyncSequence+Helpers.swift @@ -13,8 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) extension AsyncSequence { internal func collect() async throws -> [Element] { @@ -27,5 +25,3 @@ extension AsyncSequence { return try await self.reduce(0) { count, _ in count + 1 } } } - -#endif // compiler(>=5.6) diff --git a/Tests/GRPCTests/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachineTests.swift b/Tests/GRPCTests/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachineTests.swift index 6951f58ff..b1742e01f 100644 --- a/Tests/GRPCTests/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachineTests.swift +++ b/Tests/GRPCTests/AsyncAwaitSupport/AsyncServerHandler/ServerHandlerStateMachine/ServerHandlerStateMachineTests.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) @testable import GRPC import NIOCore import NIOEmbedded @@ -328,4 +327,3 @@ extension ServerHandlerStateMachine.CancelAction { XCTAssertEqual(self, .cancelAndNilOutHandlerComponents) } } -#endif // compiler(>=5.6) diff --git a/Tests/GRPCTests/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachineStreamStateTests.swift b/Tests/GRPCTests/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachineStreamStateTests.swift index 383ec41e1..f42b3c648 100644 --- a/Tests/GRPCTests/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachineStreamStateTests.swift +++ b/Tests/GRPCTests/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachineStreamStateTests.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) @testable import GRPC import XCTest @@ -126,5 +125,3 @@ internal final class ServerInterceptorStateMachineStreamStateTests: GRPCTestCase XCTAssertEqual(state, .done) } } - -#endif // compiler(>=5.6) diff --git a/Tests/GRPCTests/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachineTests.swift b/Tests/GRPCTests/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachineTests.swift index 6f6b9a9b7..ce7464fde 100644 --- a/Tests/GRPCTests/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachineTests.swift +++ b/Tests/GRPCTests/AsyncAwaitSupport/AsyncServerHandler/ServerInterceptorStateMachine/ServerInterceptorStateMachineTests.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) @testable import GRPC import NIOEmbedded import XCTest @@ -185,5 +184,3 @@ extension ServerInterceptorStateMachine.CancelAction { XCTAssertEqual(self, .nilOutInterceptorPipeline) } } - -#endif // compiler(>=5.6) diff --git a/Tests/GRPCTests/AsyncAwaitSupport/GRPCAsyncRequestStreamTests.swift b/Tests/GRPCTests/AsyncAwaitSupport/GRPCAsyncRequestStreamTests.swift index b2b7871f5..708b5da55 100644 --- a/Tests/GRPCTests/AsyncAwaitSupport/GRPCAsyncRequestStreamTests.swift +++ b/Tests/GRPCTests/AsyncAwaitSupport/GRPCAsyncRequestStreamTests.swift @@ -13,8 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) - import GRPC import XCTest @@ -31,4 +29,3 @@ final class GRPCAsyncRequestStreamTests: XCTestCase { XCTAssertEqual(results, [1]) } } -#endif diff --git a/Tests/GRPCTests/AsyncAwaitSupport/GRPCAsyncResponseStreamWriterTests.swift b/Tests/GRPCTests/AsyncAwaitSupport/GRPCAsyncResponseStreamWriterTests.swift index a299f2c2c..2c903d15b 100644 --- a/Tests/GRPCTests/AsyncAwaitSupport/GRPCAsyncResponseStreamWriterTests.swift +++ b/Tests/GRPCTests/AsyncAwaitSupport/GRPCAsyncResponseStreamWriterTests.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import GRPC import XCTest @@ -31,4 +30,3 @@ final class GRPCAsyncResponseStreamWriterTests: XCTestCase { XCTAssertEqual(results[0].1, .disabled) } } -#endif diff --git a/Tests/GRPCTests/AsyncAwaitSupport/InterceptorsAsyncTests.swift b/Tests/GRPCTests/AsyncAwaitSupport/InterceptorsAsyncTests.swift index 8ff554ebc..dca269d66 100644 --- a/Tests/GRPCTests/AsyncAwaitSupport/InterceptorsAsyncTests.swift +++ b/Tests/GRPCTests/AsyncAwaitSupport/InterceptorsAsyncTests.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import EchoImplementation import EchoModel import GRPC @@ -169,5 +168,3 @@ class InterceptorsAsyncTests: GRPCTestCase { } } } - -#endif diff --git a/Tests/GRPCTests/AsyncAwaitSupport/XCTest+AsyncAwait.swift b/Tests/GRPCTests/AsyncAwaitSupport/XCTest+AsyncAwait.swift index 5041830a6..7e8ff10ca 100644 --- a/Tests/GRPCTests/AsyncAwaitSupport/XCTest+AsyncAwait.swift +++ b/Tests/GRPCTests/AsyncAwaitSupport/XCTest+AsyncAwait.swift @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) import XCTest @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) @@ -31,7 +30,7 @@ internal func XCTAssertThrowsError( } } -fileprivate enum TaskResult { +private enum TaskResult { case operation(Result) case cancellation } @@ -70,5 +69,3 @@ func withTaskCancelledAfter( try await group.waitForAll() } } - -#endif // compiler(>=5.6) diff --git a/Tests/GRPCTests/ClientTimeoutTests.swift b/Tests/GRPCTests/ClientTimeoutTests.swift index 9930df17d..0bf157101 100644 --- a/Tests/GRPCTests/ClientTimeoutTests.swift +++ b/Tests/GRPCTests/ClientTimeoutTests.swift @@ -164,10 +164,8 @@ class ClientTimeoutTests: GRPCTestCase { } } -#if compiler(>=5.6) // Unchecked as it uses an 'EmbeddedChannel'. extension EmbeddedGRPCChannel: @unchecked Sendable {} -#endif // compiler(>=5.6) private final class EmbeddedGRPCChannel: GRPCChannel { let embeddedChannel: EmbeddedChannel diff --git a/Tests/GRPCTests/Codegen/Normalization/normalization.grpc.swift b/Tests/GRPCTests/Codegen/Normalization/normalization.grpc.swift index 112d29900..98be1ca17 100644 --- a/Tests/GRPCTests/Codegen/Normalization/normalization.grpc.swift +++ b/Tests/GRPCTests/Codegen/Normalization/normalization.grpc.swift @@ -234,10 +234,8 @@ extension Normalization_NormalizationClientProtocol { } } -#if compiler(>=5.6) @available(*, deprecated) extension Normalization_NormalizationClient: @unchecked Sendable {} -#endif // compiler(>=5.6) @available(*, deprecated, renamed: "Normalization_NormalizationNIOClient") internal final class Normalization_NormalizationClient: Normalization_NormalizationClientProtocol { @@ -293,7 +291,6 @@ internal struct Normalization_NormalizationNIOClient: Normalization_Normalizatio } } -#if compiler(>=5.6) @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) internal protocol Normalization_NormalizationAsyncClientProtocol: GRPCClient { static var serviceDescriptor: GRPCServiceDescriptor { get } @@ -599,9 +596,7 @@ internal struct Normalization_NormalizationAsyncClient: Normalization_Normalizat } } -#endif // compiler(>=5.6) - -internal protocol Normalization_NormalizationClientInterceptorFactoryProtocol: GRPCSendable { +internal protocol Normalization_NormalizationClientInterceptorFactoryProtocol: Sendable { /// - Returns: Interceptors to use when invoking 'Unary'. func makeUnaryInterceptors() -> [ClientInterceptor] @@ -806,8 +801,6 @@ extension Normalization_NormalizationProvider { } } -#if compiler(>=5.6) - /// To implement a server, implement an object which conforms to this protocol. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) internal protocol Normalization_NormalizationAsyncProvider: CallHandlerProvider { @@ -956,8 +949,6 @@ extension Normalization_NormalizationAsyncProvider { } } -#endif // compiler(>=5.6) - internal protocol Normalization_NormalizationServerInterceptorFactoryProtocol { /// - Returns: Interceptors to use when handling 'Unary'. diff --git a/Tests/GRPCTests/ConnectionManagerTests.swift b/Tests/GRPCTests/ConnectionManagerTests.swift index 174f73112..92f2333f3 100644 --- a/Tests/GRPCTests/ConnectionManagerTests.swift +++ b/Tests/GRPCTests/ConnectionManagerTests.swift @@ -1272,10 +1272,8 @@ internal struct Change: Hashable, CustomStringConvertible { } } -#if compiler(>=5.6) // Unchecked as all mutable state is modified from a serial queue. extension RecordingConnectivityDelegate: @unchecked Sendable {} -#endif // compiler(>=5.6) internal class RecordingConnectivityDelegate: ConnectivityStateDelegate { private let serialQueue = DispatchQueue(label: "io.grpc.testing") diff --git a/Tests/GRPCTests/ConnectionPool/ConnectionPoolDelegates.swift b/Tests/GRPCTests/ConnectionPool/ConnectionPoolDelegates.swift index 3691706ff..4a063bfa3 100644 --- a/Tests/GRPCTests/ConnectionPool/ConnectionPoolDelegates.swift +++ b/Tests/GRPCTests/ConnectionPool/ConnectionPoolDelegates.swift @@ -22,26 +22,16 @@ final class IsConnectingDelegate: GRPCConnectionPoolDelegate { private var connecting = Set() private var active = Set() - enum StateNotifacation: Hashable, GRPCSendable { + enum StateNotifacation: Hashable, Sendable { case connecting case connected } - #if swift(>=5.6) private let onStateChange: @Sendable (StateNotifacation) -> Void - #else - private let onStateChange: (StateNotifacation) -> Void - #endif - #if swift(>=5.6) init(onStateChange: @escaping @Sendable (StateNotifacation) -> Void) { self.onStateChange = onStateChange } - #else - init(onStateChange: @escaping (StateNotifacation) -> Void) { - self.onStateChange = onStateChange - } - #endif func startedConnecting(id: GRPCConnectionID) { let didStartConnecting: Bool = self.lock.withLock { @@ -94,9 +84,7 @@ final class IsConnectingDelegate: GRPCConnectionPoolDelegate { func connectionUtilizationChanged(id: GRPCConnectionID, streamsUsed: Int, streamCapacity: Int) {} } -#if swift(>=5.6) extension IsConnectingDelegate: @unchecked Sendable {} -#endif final class EventRecordingConnectionPoolDelegate: GRPCConnectionPoolDelegate { struct UnexpectedEvent: Error { @@ -200,6 +188,4 @@ final class EventRecordingConnectionPoolDelegate: GRPCConnectionPoolDelegate { } } -#if swift(>=5.6) extension EventRecordingConnectionPoolDelegate: @unchecked Sendable {} -#endif // swift(>=5.6) diff --git a/Tests/GRPCTests/DelegatingErrorHandlerTests.swift b/Tests/GRPCTests/DelegatingErrorHandlerTests.swift index b3cf17ddc..5b5cfc413 100644 --- a/Tests/GRPCTests/DelegatingErrorHandlerTests.swift +++ b/Tests/GRPCTests/DelegatingErrorHandlerTests.swift @@ -44,9 +44,7 @@ class DelegatingErrorHandlerTests: GRPCTestCase { XCTAssertEqual(delegate.errors[0] as? NIOSSLError, .writeDuringTLSShutdown) } } -#endif // canImport(NIOSSL) -#if canImport(NIOSSL) && compiler(>=5.6) // Unchecked because the error recorder is only ever used in the context of an EmbeddedChannel. extension DelegatingErrorHandlerTests.ErrorRecorder: @unchecked Sendable {} -#endif // canImport(NIOSSL) && compiler(>=5.6) +#endif // canImport(NIOSSL) diff --git a/Tests/GRPCTests/EchoHelpers/Interceptors/EchoInterceptorFactories.swift b/Tests/GRPCTests/EchoHelpers/Interceptors/EchoInterceptorFactories.swift index 10e140699..01c00d57e 100644 --- a/Tests/GRPCTests/EchoHelpers/Interceptors/EchoInterceptorFactories.swift +++ b/Tests/GRPCTests/EchoHelpers/Interceptors/EchoInterceptorFactories.swift @@ -19,12 +19,8 @@ import GRPC // MARK: - Client internal final class EchoClientInterceptors: Echo_EchoClientInterceptorFactoryProtocol { - #if swift(>=5.6) internal typealias Factory = @Sendable () -> ClientInterceptor - #else - internal typealias Factory = () -> ClientInterceptor - #endif // swift(>=5.6) private let factories: [Factory] internal init(_ factories: Factory...) { diff --git a/Tests/GRPCTests/EchoMetadataTests.swift b/Tests/GRPCTests/EchoMetadataTests.swift index 74c17b063..567450d5e 100644 --- a/Tests/GRPCTests/EchoMetadataTests.swift +++ b/Tests/GRPCTests/EchoMetadataTests.swift @@ -81,11 +81,9 @@ internal final class EchoMetadataTests: GRPCTestCase { self.testServiceDescriptor(Echo_EchoClientMetadata.serviceDescriptor) self.testServiceDescriptor(Echo_EchoServerMetadata.serviceDescriptor) - #if swift(>=5.6) if #available(macOS 12, *) { self.testServiceDescriptor(Echo_EchoAsyncClient.serviceDescriptor) } - #endif } func testGet() { diff --git a/Tests/GRPCTests/ErrorRecordingDelegate.swift b/Tests/GRPCTests/ErrorRecordingDelegate.swift index 477be9a16..2991ad26a 100644 --- a/Tests/GRPCTests/ErrorRecordingDelegate.swift +++ b/Tests/GRPCTests/ErrorRecordingDelegate.swift @@ -18,10 +18,8 @@ import Logging import NIOConcurrencyHelpers import XCTest -#if compiler(>=5.6) // Unchecked as all mutable state is accessed and modified behind a lock. extension ErrorRecordingDelegate: @unchecked Sendable {} -#endif // compiler(>=5.6) final class ErrorRecordingDelegate: ClientErrorDelegate { private let lock: NIOLock diff --git a/Tests/GRPCTests/GRPCAsyncClientCallTests.swift b/Tests/GRPCTests/GRPCAsyncClientCallTests.swift index 067c41504..7f2fb3502 100644 --- a/Tests/GRPCTests/GRPCAsyncClientCallTests.swift +++ b/Tests/GRPCTests/GRPCAsyncClientCallTests.swift @@ -13,8 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) - import EchoImplementation import EchoModel @testable import GRPC @@ -211,7 +209,7 @@ class GRPCAsyncClientCallTests: GRPCTestCase { // Workaround https://bugs.swift.org/browse/SR-15070 (compiler crashes when defining a class/actor // in an async context). @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) -fileprivate actor RequestResponseCounter { +private actor RequestResponseCounter { var numResponses = 0 var numRequests = 0 @@ -223,5 +221,3 @@ fileprivate actor RequestResponseCounter { self.numRequests += 1 } } - -#endif diff --git a/Tests/GRPCTests/GRPCAsyncServerHandlerTests.swift b/Tests/GRPCTests/GRPCAsyncServerHandlerTests.swift index 85460e9f6..057d37713 100644 --- a/Tests/GRPCTests/GRPCAsyncServerHandlerTests.swift +++ b/Tests/GRPCTests/GRPCAsyncServerHandlerTests.swift @@ -13,8 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.6) - @testable import GRPC import NIOCore import NIOEmbedded @@ -614,4 +612,3 @@ extension Optional where Wrapped == GRPCServerResponsePart { } } } -#endif diff --git a/Tests/GRPCTests/GRPCInteroperabilityTests.swift b/Tests/GRPCTests/GRPCInteroperabilityTests.swift index 9f82d005d..14efae0fe 100644 --- a/Tests/GRPCTests/GRPCInteroperabilityTests.swift +++ b/Tests/GRPCTests/GRPCInteroperabilityTests.swift @@ -252,7 +252,6 @@ class GRPCSecureInteroperabilityTests: GRPCInsecureInteroperabilityTests { } #endif // canImport(NIOSSL) -#if compiler(>=5.6) @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) class GRPCInsecureInteroperabilityAsyncTests: GRPCInsecureInteroperabilityTests { override func makeProvider() -> CallHandlerProvider { @@ -418,4 +417,3 @@ class GRPCSecureInteroperabilityAsyncTests: GRPCInsecureInteroperabilityAsyncTes } } #endif // canImport(NIOSSL) -#endif // compiler(>=5.6) diff --git a/Tests/GRPCTests/InterceptorsTests.swift b/Tests/GRPCTests/InterceptorsTests.swift index 1d8176abb..a57b9cd36 100644 --- a/Tests/GRPCTests/InterceptorsTests.swift +++ b/Tests/GRPCTests/InterceptorsTests.swift @@ -158,9 +158,7 @@ class HelloWorldProvider: Helloworld_GreeterProvider { } } -#if swift(>=5.6) extension HelloWorldClientInterceptorFactory: @unchecked Sendable {} -#endif // swift(>=5.6) private class HelloWorldClientInterceptorFactory: Helloworld_GreeterClientInterceptorFactoryProtocol { diff --git a/Tests/GRPCTests/XCTestHelpers.swift b/Tests/GRPCTests/XCTestHelpers.swift index d0ea66481..6f23221c6 100644 --- a/Tests/GRPCTests/XCTestHelpers.swift +++ b/Tests/GRPCTests/XCTestHelpers.swift @@ -660,8 +660,6 @@ struct ExpressionMatcher { } } -#if compiler(>=5.6) - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) func assertThat( _ expression: @autoclosure @escaping () async throws -> Value, @@ -695,5 +693,3 @@ func assertThat( XCTFail("ACTUAL: \(actual), EXPECTED: \(expected)", file: file, line: line) } } - -#endif From 123628f1d357b34d711abec9a681da5165e29456 Mon Sep 17 00:00:00 2001 From: George Barnett Date: Wed, 12 Apr 2023 10:27:11 +0100 Subject: [PATCH 2/2] Use GRPCPreconcurrencySendable --- Sources/GRPC/AsyncAwaitSupport/GRPCSendable.swift | 1 - Sources/GRPC/ClientErrorDelegate.swift | 3 +-- Sources/GRPC/ConnectivityState.swift | 3 +-- Sources/GRPC/GRPCChannel/GRPCChannel.swift | 3 +-- Sources/GRPC/GRPCClient.swift | 3 +-- 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Sources/GRPC/AsyncAwaitSupport/GRPCSendable.swift b/Sources/GRPC/AsyncAwaitSupport/GRPCSendable.swift index f1c00d300..a94525a48 100644 --- a/Sources/GRPC/AsyncAwaitSupport/GRPCSendable.swift +++ b/Sources/GRPC/AsyncAwaitSupport/GRPCSendable.swift @@ -18,7 +18,6 @@ import NIOCore @available(*, deprecated, renamed: "Swift.Sendable") public typealias GRPCSendable = Swift.Sendable -@available(*, deprecated, message: "Use @preconcurrency Swift.Sendable") @preconcurrency public protocol GRPCPreconcurrencySendable: Sendable {} diff --git a/Sources/GRPC/ClientErrorDelegate.swift b/Sources/GRPC/ClientErrorDelegate.swift index 93119a7cb..ee3734ae2 100644 --- a/Sources/GRPC/ClientErrorDelegate.swift +++ b/Sources/GRPC/ClientErrorDelegate.swift @@ -22,8 +22,7 @@ import Logging /// The intended use of this protocol is with ``ClientConnection``. In order to avoid retain /// cycles, classes implementing this delegate **must not** maintain a strong reference to the /// ``ClientConnection``. -@preconcurrency -public protocol ClientErrorDelegate: AnyObject, Sendable { +public protocol ClientErrorDelegate: AnyObject, GRPCPreconcurrencySendable { /// Called when the client catches an error. /// /// - Parameters: diff --git a/Sources/GRPC/ConnectivityState.swift b/Sources/GRPC/ConnectivityState.swift index 3ab871d46..ff238ce65 100644 --- a/Sources/GRPC/ConnectivityState.swift +++ b/Sources/GRPC/ConnectivityState.swift @@ -47,8 +47,7 @@ public enum ConnectivityState: Sendable { case shutdown } -@preconcurrency -public protocol ConnectivityStateDelegate: AnyObject, Sendable { +public protocol ConnectivityStateDelegate: AnyObject, GRPCPreconcurrencySendable { /// Called when a change in ``ConnectivityState`` has occurred. /// /// - Parameter oldState: The old connectivity state. diff --git a/Sources/GRPC/GRPCChannel/GRPCChannel.swift b/Sources/GRPC/GRPCChannel/GRPCChannel.swift index 2e045d069..b34ef5c12 100644 --- a/Sources/GRPC/GRPCChannel/GRPCChannel.swift +++ b/Sources/GRPC/GRPCChannel/GRPCChannel.swift @@ -17,8 +17,7 @@ import NIOCore import NIOHTTP2 import SwiftProtobuf -@preconcurrency -public protocol GRPCChannel: Sendable { +public protocol GRPCChannel: GRPCPreconcurrencySendable { /// Makes a gRPC call on the channel with requests and responses conforming to /// `SwiftProtobuf.Message`. /// diff --git a/Sources/GRPC/GRPCClient.swift b/Sources/GRPC/GRPCClient.swift index 92e09ff9c..783c3f842 100644 --- a/Sources/GRPC/GRPCClient.swift +++ b/Sources/GRPC/GRPCClient.swift @@ -19,8 +19,7 @@ import NIOHTTP2 import SwiftProtobuf /// A gRPC client. -@preconcurrency -public protocol GRPCClient: Sendable { +public protocol GRPCClient: GRPCPreconcurrencySendable { /// The gRPC channel over which RPCs are sent and received. Note that this is distinct /// from `NIO.Channel`. var channel: GRPCChannel { get }