diff --git a/Package.swift b/Package.swift index 073f237..51cb196 100644 --- a/Package.swift +++ b/Package.swift @@ -42,12 +42,12 @@ let products: [Product] = [ let dependencies: [Package.Dependency] = [ .package( - url: "https://github.com/grpc/grpc-swift.git", - from: "2.2.0" + url: "https://github.com/grpc/grpc-swift-2.git", + from: "2.0.0" ), .package( url: "https://github.com/grpc/grpc-swift-protobuf.git", - from: "1.3.0" + from: "2.0.0" ), .package( url: "https://github.com/apple/swift-protobuf.git", @@ -65,12 +65,12 @@ let dependencies: [Package.Dependency] = [ // ------------------------------------------------------------------------------------------------- -// This adds some build settings which allow us to map "@available(gRPCSwiftExtras 1.x, *)" to +// This adds some build settings which allow us to map "@available(gRPCSwiftExtras 2.x, *)" to // the appropriate OS platforms. let nextMinorVersion = 1 let availabilitySettings: [SwiftSetting] = (0 ... nextMinorVersion).map { minor in let name = "gRPCSwiftExtras" - let version = "1.\(minor)" + let version = "2.\(minor)" let platforms = "macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0" let setting = "AvailabilityMacro=\(name) \(version):\(platforms)" return .enableExperimentalFeature(setting) @@ -91,7 +91,7 @@ let targets: [Target] = [ .target( name: "GRPCHealthService", dependencies: [ - .product(name: "GRPCCore", package: "grpc-swift"), + .product(name: "GRPCCore", package: "grpc-swift-2"), .product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"), .product(name: "SwiftProtobuf", package: "swift-protobuf"), ], @@ -101,8 +101,8 @@ let targets: [Target] = [ name: "GRPCHealthServiceTests", dependencies: [ .target(name: "GRPCHealthService"), - .product(name: "GRPCCore", package: "grpc-swift"), - .product(name: "GRPCInProcessTransport", package: "grpc-swift"), + .product(name: "GRPCCore", package: "grpc-swift-2"), + .product(name: "GRPCInProcessTransport", package: "grpc-swift-2"), ], swiftSettings: defaultSwiftSettings ), @@ -111,7 +111,7 @@ let targets: [Target] = [ .target( name: "GRPCReflectionService", dependencies: [ - .product(name: "GRPCCore", package: "grpc-swift"), + .product(name: "GRPCCore", package: "grpc-swift-2"), .product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"), .product(name: "SwiftProtobuf", package: "swift-protobuf"), ], @@ -121,8 +121,8 @@ let targets: [Target] = [ name: "GRPCReflectionServiceTests", dependencies: [ .target(name: "GRPCReflectionService"), - .product(name: "GRPCCore", package: "grpc-swift"), - .product(name: "GRPCInProcessTransport", package: "grpc-swift"), + .product(name: "GRPCCore", package: "grpc-swift-2"), + .product(name: "GRPCInProcessTransport", package: "grpc-swift-2"), .product(name: "SwiftProtobuf", package: "swift-protobuf"), ], resources: [ @@ -135,7 +135,7 @@ let targets: [Target] = [ .target( name: "GRPCOTelTracingInterceptors", dependencies: [ - .product(name: "GRPCCore", package: "grpc-swift"), + .product(name: "GRPCCore", package: "grpc-swift-2"), .product(name: "Tracing", package: "swift-distributed-tracing"), ], swiftSettings: defaultSwiftSettings @@ -144,7 +144,7 @@ let targets: [Target] = [ name: "GRPCOTelTracingInterceptorsTests", dependencies: [ .target(name: "GRPCOTelTracingInterceptors"), - .product(name: "GRPCCore", package: "grpc-swift"), + .product(name: "GRPCCore", package: "grpc-swift-2"), .product(name: "Tracing", package: "swift-distributed-tracing"), ], swiftSettings: defaultSwiftSettings @@ -154,7 +154,7 @@ let targets: [Target] = [ .target( name: "GRPCServiceLifecycle", dependencies: [ - .product(name: "GRPCCore", package: "grpc-swift"), + .product(name: "GRPCCore", package: "grpc-swift-2"), .product(name: "ServiceLifecycle", package: "swift-service-lifecycle"), ], swiftSettings: defaultSwiftSettings @@ -163,9 +163,9 @@ let targets: [Target] = [ name: "GRPCServiceLifecycleTests", dependencies: [ .target(name: "GRPCServiceLifecycle"), - .product(name: "GRPCCore", package: "grpc-swift"), + .product(name: "GRPCCore", package: "grpc-swift-2"), .product(name: "ServiceLifecycleTestKit", package: "swift-service-lifecycle"), - .product(name: "GRPCInProcessTransport", package: "grpc-swift"), + .product(name: "GRPCInProcessTransport", package: "grpc-swift-2"), ], swiftSettings: defaultSwiftSettings ), @@ -174,7 +174,7 @@ let targets: [Target] = [ .target( name: "GRPCInteropTests", dependencies: [ - .product(name: "GRPCCore", package: "grpc-swift"), + .product(name: "GRPCCore", package: "grpc-swift-2"), .product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"), ], swiftSettings: defaultSwiftSettings @@ -184,8 +184,8 @@ let targets: [Target] = [ name: "InProcessInteropTests", dependencies: [ .target(name: "GRPCInteropTests"), - .product(name: "GRPCCore", package: "grpc-swift"), - .product(name: "GRPCInProcessTransport", package: "grpc-swift"), + .product(name: "GRPCCore", package: "grpc-swift-2"), + .product(name: "GRPCInProcessTransport", package: "grpc-swift-2"), ], swiftSettings: defaultSwiftSettings ), diff --git a/Sources/GRPCHealthService/HealthService+Service.swift b/Sources/GRPCHealthService/HealthService+Service.swift index e4c31b3..be158b8 100644 --- a/Sources/GRPCHealthService/HealthService+Service.swift +++ b/Sources/GRPCHealthService/HealthService+Service.swift @@ -17,14 +17,14 @@ internal import GRPCCore private import Synchronization -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) extension HealthService { internal struct Service: Grpc_Health_V1_Health.ServiceProtocol { private let state = Self.State() } } -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) extension HealthService.Service { func check( request: ServerRequest, @@ -71,7 +71,7 @@ extension HealthService.Service { } } -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) extension HealthService.Service { private final class State: Sendable { // The state of each service keyed by the fully qualified service name. diff --git a/Sources/GRPCHealthService/HealthService.swift b/Sources/GRPCHealthService/HealthService.swift index eab4b36..9f3e0ef 100644 --- a/Sources/GRPCHealthService/HealthService.swift +++ b/Sources/GRPCHealthService/HealthService.swift @@ -41,7 +41,7 @@ public import GRPCCore /// // ... /// } /// ``` -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) public struct HealthService: Sendable, RegistrableRPCService { /// An implementation of the `grpc.health.v1.Health` service. private let service: Service @@ -63,7 +63,7 @@ public struct HealthService: Sendable, RegistrableRPCService { } } -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) extension HealthService { /// Provides status updates to ``HealthService``. public struct Provider: Sendable { @@ -107,7 +107,7 @@ extension HealthService { } } -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) extension Grpc_Health_V1_HealthCheckResponse.ServingStatus { package init(_ status: ServingStatus) { switch status.value { diff --git a/Sources/GRPCHealthService/ServingStatus.swift b/Sources/GRPCHealthService/ServingStatus.swift index 20c62e4..036d102 100644 --- a/Sources/GRPCHealthService/ServingStatus.swift +++ b/Sources/GRPCHealthService/ServingStatus.swift @@ -18,7 +18,7 @@ /// /// - ``ServingStatus/serving`` indicates that a service is healthy. /// - ``ServingStatus/notServing`` indicates that a service is unhealthy. -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) public struct ServingStatus: Sendable, Hashable { internal enum Value: Sendable, Hashable { case serving diff --git a/Sources/GRPCInteropTests/AssertionFailure.swift b/Sources/GRPCInteropTests/AssertionFailure.swift index 9f20c37..dddba33 100644 --- a/Sources/GRPCInteropTests/AssertionFailure.swift +++ b/Sources/GRPCInteropTests/AssertionFailure.swift @@ -17,7 +17,7 @@ /// Failure assertion for interoperability testing. /// /// This is required because the tests must be able to run without XCTest. -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) public struct AssertionFailure: Error { public var message: String public var file: String @@ -31,7 +31,7 @@ public struct AssertionFailure: Error { } /// Asserts that the value of an expression is `true`. -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) public func assertTrue( _ expression: @autoclosure () throws -> Bool, _ message: String = "The statement is not true.", @@ -44,7 +44,7 @@ public func assertTrue( } /// Asserts that the two given values are equal. -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) public func assertEqual( _ value1: T, _ value2: T, diff --git a/Sources/GRPCInteropTests/InteroperabilityTestCase.swift b/Sources/GRPCInteropTests/InteroperabilityTestCase.swift index 814a8a8..85515f5 100644 --- a/Sources/GRPCInteropTests/InteroperabilityTestCase.swift +++ b/Sources/GRPCInteropTests/InteroperabilityTestCase.swift @@ -15,7 +15,7 @@ */ public import GRPCCore -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) public protocol InteroperabilityTest { /// Run a test case using the given connection. /// @@ -48,7 +48,7 @@ public protocol InteroperabilityTest { /// Note: Tests for compression have not been implemented yet as compression is /// not supported. Once the API which allows for compression will be implemented /// these tests should be added. -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) public enum InteroperabilityTestCase: String, CaseIterable, Sendable { case emptyUnary = "empty_unary" case largeUnary = "large_unary" @@ -70,7 +70,7 @@ public enum InteroperabilityTestCase: String, CaseIterable, Sendable { } } -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) extension InteroperabilityTestCase { /// Return a new instance of the test case. public func makeTest() -> any InteroperabilityTest { diff --git a/Sources/GRPCInteropTests/InteroperabilityTestCases.swift b/Sources/GRPCInteropTests/InteroperabilityTestCases.swift index b583da6..5750c87 100644 --- a/Sources/GRPCInteropTests/InteroperabilityTestCases.swift +++ b/Sources/GRPCInteropTests/InteroperabilityTestCases.swift @@ -36,7 +36,7 @@ private import struct Foundation.Data /// Client asserts: /// - call was successful /// - response is non-null -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) struct EmptyUnary: InteroperabilityTest { func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) @@ -70,7 +70,7 @@ struct EmptyUnary: InteroperabilityTest { /// - response payload body is 314159 bytes in size /// - clients are free to assert that the response payload body contents are zero and comparing /// the entire response message against a golden response -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) struct LargeUnary: InteroperabilityTest { func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) @@ -146,7 +146,7 @@ struct LargeUnary: InteroperabilityTest { /// - Response payload body is 314159 bytes in size. /// - Clients are free to assert that the response payload body contents are zeros and comparing the /// entire response message against a golden response. -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) class ClientCompressedUnary: InteroperabilityTest { func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) @@ -256,7 +256,7 @@ class ClientCompressedUnary: InteroperabilityTest { /// - response payload body is 314159 bytes in size in both cases. /// - clients are free to assert that the response payload body contents are zero and comparing the /// entire response message against a golden response -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) class ServerCompressedUnary: InteroperabilityTest { func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) @@ -346,7 +346,7 @@ class ServerCompressedUnary: InteroperabilityTest { /// Client asserts: /// - call was successful /// - response aggregated_payload_size is 74922 -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) struct ClientStreaming: InteroperabilityTest { func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) @@ -397,7 +397,7 @@ struct ClientStreaming: InteroperabilityTest { /// - response payload bodies are sized (in order): 31415, 9, 2653, 58979 /// - clients are free to assert that the response payload body contents are zero and /// comparing the entire response messages against golden responses -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) struct ServerStreaming: InteroperabilityTest { func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) @@ -473,7 +473,7 @@ struct ServerStreaming: InteroperabilityTest { /// - response payload bodies are sized (in order): 31415, 92653 /// - clients are free to assert that the response payload body contents are zero and comparing the /// entire response messages against golden responses -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) class ServerCompressedStreaming: InteroperabilityTest { func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) @@ -586,7 +586,7 @@ class ServerCompressedStreaming: InteroperabilityTest { /// - response payload bodies are sized (in order): 31415, 9, 2653, 58979 /// - clients are free to assert that the response payload body contents are zero and /// comparing the entire response messages against golden responses -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) struct PingPong: InteroperabilityTest { func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) @@ -653,7 +653,7 @@ struct PingPong: InteroperabilityTest { /// Client asserts: /// - call was successful /// - exactly zero responses -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) struct EmptyStream: InteroperabilityTest { func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) @@ -709,7 +709,7 @@ struct EmptyStream: InteroperabilityTest { /// received in the initial metadata for calls in Procedure steps 1 and 2. /// - metadata with key "x-grpc-test-echo-trailing-bin" and value 0xababab is received in the /// trailing metadata for calls in Procedure steps 1 and 2. -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) struct CustomMetadata: InteroperabilityTest { let initialMetadataName = "x-grpc-test-echo-initial" let initialMetadataValue = "test_initial_metadata_value" @@ -830,7 +830,7 @@ struct CustomMetadata: InteroperabilityTest { /// Client asserts: /// - received status code is the same as the sent code for both Procedure steps 1 and 2 /// - received status message is the same as the sent message for both Procedure steps 1 and 2 -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) struct StatusCodeAndMessage: InteroperabilityTest { let expectedCode = 2 let expectedMessage = "test status message" @@ -908,7 +908,7 @@ struct StatusCodeAndMessage: InteroperabilityTest { /// - received status code is the same as the sent code for Procedure step 1 /// - received status message is the same as the sent message for Procedure step 1, including all /// whitespace characters -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) struct SpecialStatusMessage: InteroperabilityTest { func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) @@ -951,7 +951,7 @@ struct SpecialStatusMessage: InteroperabilityTest { /// /// Client asserts: /// - received status code is 12 (UNIMPLEMENTED) -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) struct UnimplementedMethod: InteroperabilityTest { func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) @@ -984,7 +984,7 @@ struct UnimplementedMethod: InteroperabilityTest { /// /// Client asserts: /// - received status code is 12 (UNIMPLEMENTED) -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) struct UnimplementedService: InteroperabilityTest { func run(client: GRPCClient) async throws { let unimplementedServiceClient = Grpc_Testing_UnimplementedService.Client(wrapping: client) diff --git a/Sources/GRPCInteropTests/TestService.swift b/Sources/GRPCInteropTests/TestService.swift index 1fa20f2..f07f576 100644 --- a/Sources/GRPCInteropTests/TestService.swift +++ b/Sources/GRPCInteropTests/TestService.swift @@ -23,7 +23,7 @@ private import struct FoundationEssentials.Data private import struct Foundation.Data #endif -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) public struct TestService: Grpc_Testing_TestService.ServiceProtocol { public init() {} @@ -234,7 +234,7 @@ public struct TestService: Grpc_Testing_TestService.ServiceProtocol { } } -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) extension Metadata { fileprivate func makeInitialAndTrailingMetadata() -> (Metadata, Metadata) { var initialMetadata = Metadata() diff --git a/Sources/GRPCOTelTracingInterceptors/HookedAsyncSequence.swift b/Sources/GRPCOTelTracingInterceptors/HookedAsyncSequence.swift index c048963..ed7ae43 100644 --- a/Sources/GRPCOTelTracingInterceptors/HookedAsyncSequence.swift +++ b/Sources/GRPCOTelTracingInterceptors/HookedAsyncSequence.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) internal struct HookedRPCAsyncSequence: AsyncSequence, Sendable where Wrapped.Element: Sendable { private let wrapped: Wrapped diff --git a/Sources/GRPCOTelTracingInterceptors/HookedWriter.swift b/Sources/GRPCOTelTracingInterceptors/HookedWriter.swift index 8b1f39e..63dd80c 100644 --- a/Sources/GRPCOTelTracingInterceptors/HookedWriter.swift +++ b/Sources/GRPCOTelTracingInterceptors/HookedWriter.swift @@ -16,7 +16,7 @@ internal import GRPCCore internal import Tracing -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) struct HookedWriter: RPCWriterProtocol { private let writer: any RPCWriterProtocol private let afterEachWrite: @Sendable () -> Void diff --git a/Sources/GRPCOTelTracingInterceptors/Tracing/ClientOTelTracingInterceptor.swift b/Sources/GRPCOTelTracingInterceptors/Tracing/ClientOTelTracingInterceptor.swift index 4be57ed..cf22f14 100644 --- a/Sources/GRPCOTelTracingInterceptors/Tracing/ClientOTelTracingInterceptor.swift +++ b/Sources/GRPCOTelTracingInterceptors/Tracing/ClientOTelTracingInterceptor.swift @@ -29,7 +29,7 @@ package import Tracing /// OpenTelemetry's documentation on: /// - https://opentelemetry.io/docs/specs/semconv/rpc/rpc-spans /// - https://opentelemetry.io/docs/specs/semconv/rpc/grpc/ -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) public struct ClientOTelTracingInterceptor: ClientInterceptor { private let injector: ClientRequestInjector private var serverHostname: String @@ -242,7 +242,7 @@ public struct ClientOTelTracingInterceptor: ClientInterceptor { /// An injector responsible for injecting the required instrumentation keys from the `ServiceContext` into /// the request metadata. -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) struct ClientRequestInjector: Instrumentation.Injector { typealias Carrier = Metadata @@ -251,7 +251,7 @@ struct ClientRequestInjector: Instrumentation.Injector { } } -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) extension Error { var grpcErrorCode: RPCError.Code? { if let rpcError = self as? RPCError { diff --git a/Sources/GRPCOTelTracingInterceptors/Tracing/ServerOTelTracingInterceptor.swift b/Sources/GRPCOTelTracingInterceptors/Tracing/ServerOTelTracingInterceptor.swift index 3c66edb..b3e1aa3 100644 --- a/Sources/GRPCOTelTracingInterceptors/Tracing/ServerOTelTracingInterceptor.swift +++ b/Sources/GRPCOTelTracingInterceptors/Tracing/ServerOTelTracingInterceptor.swift @@ -28,7 +28,7 @@ package import Tracing /// OpenTelemetry's documentation on: /// - https://opentelemetry.io/docs/specs/semconv/rpc/rpc-spans /// - https://opentelemetry.io/docs/specs/semconv/rpc/grpc/ -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) public struct ServerOTelTracingInterceptor: ServerInterceptor { private let extractor: ServerRequestExtractor private var serverHostname: String @@ -218,7 +218,7 @@ public struct ServerOTelTracingInterceptor: ServerInterceptor { } /// An extractor responsible for extracting the required instrumentation keys from request metadata. -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) struct ServerRequestExtractor: Instrumentation.Extractor { typealias Carrier = Metadata diff --git a/Sources/GRPCOTelTracingInterceptors/Tracing/SpanAttributes+GRPCTracingKeys.swift b/Sources/GRPCOTelTracingInterceptors/Tracing/SpanAttributes+GRPCTracingKeys.swift index 2c196db..0962b32 100644 --- a/Sources/GRPCOTelTracingInterceptors/Tracing/SpanAttributes+GRPCTracingKeys.swift +++ b/Sources/GRPCOTelTracingInterceptors/Tracing/SpanAttributes+GRPCTracingKeys.swift @@ -40,7 +40,7 @@ enum GRPCTracingKeys { fileprivate static let responseMetadataPrefix = "rpc.grpc.response.metadata." } -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) extension Span { // See: https://opentelemetry.io/docs/specs/semconv/rpc/rpc-spans/ func setOTelClientSpanGRPCAttributes( diff --git a/Sources/GRPCReflectionService/Service/ReflectionService+V1.swift b/Sources/GRPCReflectionService/Service/ReflectionService+V1.swift index 54113eb..1f9dda5 100644 --- a/Sources/GRPCReflectionService/Service/ReflectionService+V1.swift +++ b/Sources/GRPCReflectionService/Service/ReflectionService+V1.swift @@ -17,7 +17,7 @@ internal import GRPCCore internal import SwiftProtobuf -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) extension ReflectionService { struct V1: Grpc_Reflection_V1_ServerReflection.SimpleServiceProtocol { private typealias Response = Grpc_Reflection_V1_ServerReflectionResponse @@ -32,7 +32,7 @@ extension ReflectionService { } } -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) extension ReflectionService.V1 { private func findFileByFileName(_ fileName: String) throws(RPCError) -> FileDescriptorResponse { let data = try self.registry.serialisedFileDescriptorForDependenciesOfFile(named: fileName) diff --git a/Sources/GRPCReflectionService/Service/ReflectionService.swift b/Sources/GRPCReflectionService/Service/ReflectionService.swift index 3647be2..01fba17 100644 --- a/Sources/GRPCReflectionService/Service/ReflectionService.swift +++ b/Sources/GRPCReflectionService/Service/ReflectionService.swift @@ -33,7 +33,7 @@ public import struct Foundation.Data /// /// The service will offer information to clients about any registered services. You can register /// a service by providing its descriptor set to the service. -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) public struct ReflectionService: Sendable { private let service: ReflectionService.V1 @@ -68,7 +68,7 @@ public struct ReflectionService: Sendable { } } -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) extension ReflectionService: RegistrableRPCService { public func registerMethods( with router: inout RPCRouter @@ -77,7 +77,7 @@ extension ReflectionService: RegistrableRPCService { } } -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) extension ReflectionService { static func readSerializedFileDescriptorProto( atPath path: String diff --git a/Sources/GRPCReflectionService/Service/ReflectionServiceRegistry.swift b/Sources/GRPCReflectionService/Service/ReflectionServiceRegistry.swift index 55ed34e..408ccaa 100644 --- a/Sources/GRPCReflectionService/Service/ReflectionServiceRegistry.swift +++ b/Sources/GRPCReflectionService/Service/ReflectionServiceRegistry.swift @@ -24,7 +24,7 @@ package import struct FoundationEssentials.Data package import struct Foundation.Data #endif -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) package struct ReflectionServiceRegistry: Sendable { private struct SerializedFileDescriptor: Sendable { var bytes: Data diff --git a/Sources/GRPCServiceLifecycle/GRPCClient+Service.swift b/Sources/GRPCServiceLifecycle/GRPCClient+Service.swift index 52f711c..5416d2f 100644 --- a/Sources/GRPCServiceLifecycle/GRPCClient+Service.swift +++ b/Sources/GRPCServiceLifecycle/GRPCClient+Service.swift @@ -19,7 +19,7 @@ public import ServiceLifecycle // A `@retroactive` conformance here is okay because this project is also owned by the owners of // `GRPCCore`, and thus, the owners of `GRPCClient`. A conflicting conformance won't be added. -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) extension GRPCClient: @retroactive Service { public func run() async throws { try await withGracefulShutdownHandler { diff --git a/Sources/GRPCServiceLifecycle/GRPCServer+Service.swift b/Sources/GRPCServiceLifecycle/GRPCServer+Service.swift index 33fa499..28ba0fd 100644 --- a/Sources/GRPCServiceLifecycle/GRPCServer+Service.swift +++ b/Sources/GRPCServiceLifecycle/GRPCServer+Service.swift @@ -19,7 +19,7 @@ public import ServiceLifecycle // A `@retroactive` conformance here is okay because this project is also owned by the owners of // `GRPCCore`, and thus, the owners of `GRPCServer`. A conflicting conformance won't be added. -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) extension GRPCServer: @retroactive Service { public func run() async throws { try await withGracefulShutdownHandler { diff --git a/Tests/GRPCHealthServiceTests/HealthTests.swift b/Tests/GRPCHealthServiceTests/HealthTests.swift index e51bafd..640b282 100644 --- a/Tests/GRPCHealthServiceTests/HealthTests.swift +++ b/Tests/GRPCHealthServiceTests/HealthTests.swift @@ -20,7 +20,7 @@ import GRPCInProcessTransport import SwiftProtobuf import XCTest -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) final class HealthTests: XCTestCase { private func withHealthClient( _ body: @Sendable ( @@ -287,7 +287,7 @@ final class HealthTests: XCTestCase { } } -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) extension ServiceDescriptor { fileprivate static let testService = ServiceDescriptor(package: "test", service: "Service") } diff --git a/Tests/GRPCOTelTracingInterceptorsTests/GRPCOTelTracingInterceptorsTests.swift b/Tests/GRPCOTelTracingInterceptorsTests/GRPCOTelTracingInterceptorsTests.swift index d20e93d..b3c540f 100644 --- a/Tests/GRPCOTelTracingInterceptorsTests/GRPCOTelTracingInterceptorsTests.swift +++ b/Tests/GRPCOTelTracingInterceptorsTests/GRPCOTelTracingInterceptorsTests.swift @@ -27,7 +27,7 @@ struct OTelTracingClientInterceptorTests { "Successful RPC is recorded correctly", arguments: OTelTracingInterceptorTestAddressType.allCases ) - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func testSuccessfulRPC(addressType: OTelTracingInterceptorTestAddressType) async throws { let tracer = TestTracer() var serviceContext = ServiceContext.topLevel @@ -100,7 +100,7 @@ struct OTelTracingClientInterceptorTests { } @Test("All events are recorded when traceEachMessage is true") - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func testAllEventsRecorded() async throws { let tracer = TestTracer() var serviceContext = ServiceContext.topLevel @@ -179,7 +179,7 @@ struct OTelTracingClientInterceptorTests { } @Test("All string-valued request metadata is included if opted-in") - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func testRequestMetadataOptIn() async throws { let tracer = TestTracer() var serviceContext = ServiceContext.topLevel @@ -295,7 +295,7 @@ struct OTelTracingClientInterceptorTests { } @Test("All string-valued response metadata is included if opted-in") - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func testResponseMetadataOptIn() async throws { let tracer = TestTracer() var serviceContext = ServiceContext.topLevel @@ -411,7 +411,7 @@ struct OTelTracingClientInterceptorTests { } @Test("RPC that throws is correctly recorded") - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func testThrowingRPC() async throws { let tracer = TestTracer() var serviceContext = ServiceContext.topLevel @@ -476,7 +476,7 @@ struct OTelTracingClientInterceptorTests { } @Test("RPC with a failure response is correctly recorded") - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func testFailedRPC() async throws { let tracer = TestTracer() var serviceContext = ServiceContext.topLevel @@ -557,7 +557,7 @@ struct OTelTracingClientInterceptorTests { } @Test("Accepted server-streaming RPC that throws error during response is correctly recorded") - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func testAcceptedRPCWithError() async throws { let tracer = TestTracer() var serviceContext = ServiceContext.topLevel @@ -648,7 +648,7 @@ struct OTelTracingClientInterceptorTests { } } - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) private func getTestValues( addressType: OTelTracingInterceptorTestAddressType, methodDescriptor: MethodDescriptor @@ -714,7 +714,7 @@ struct OTelTracingServerInterceptorTests { "Successful RPC is recorded correctly", arguments: OTelTracingInterceptorTestAddressType.allCases ) - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func testSuccessfulRPC(addressType: OTelTracingInterceptorTestAddressType) async throws { let tracer = TestTracer() let methodDescriptor = MethodDescriptor( @@ -783,7 +783,7 @@ struct OTelTracingServerInterceptorTests { } @Test("All events are recorded when traceEachMessage is true") - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func testAllEventsRecorded() async throws { let tracer = TestTracer() let methodDescriptor = MethodDescriptor( @@ -861,7 +861,7 @@ struct OTelTracingServerInterceptorTests { } @Test("All string-valued request metadata is included if opted-in") - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func testRequestMetadataOptIn() async throws { let tracer = TestTracer() let methodDescriptor = MethodDescriptor( @@ -971,7 +971,7 @@ struct OTelTracingServerInterceptorTests { } @Test("All string-valued response metadata is included if opted-in") - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func testResponseMetadataOptIn() async throws { let tracer = TestTracer() let methodDescriptor = MethodDescriptor( @@ -1081,7 +1081,7 @@ struct OTelTracingServerInterceptorTests { } @Test("RPC that throws is correctly recorded") - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func testThrowingRPC() async throws { let tracer = TestTracer() let methodDescriptor = MethodDescriptor( @@ -1128,7 +1128,7 @@ struct OTelTracingServerInterceptorTests { } @Test("RPC with a failure response is correctly recorded") - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func testFailedRPC() async throws { let tracer = TestTracer() let methodDescriptor = MethodDescriptor( @@ -1191,7 +1191,7 @@ struct OTelTracingServerInterceptorTests { } } - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) private func getTestValues( addressType: OTelTracingInterceptorTestAddressType, methodDescriptor: MethodDescriptor @@ -1255,7 +1255,7 @@ struct OTelTracingServerInterceptorTests { // - MARK: Utilities -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) private func getTestSpanForMethod( tracer: TestTracer, methodDescriptor: MethodDescriptor @@ -1263,7 +1263,7 @@ private func getTestSpanForMethod( tracer.getSpan(ofOperation: methodDescriptor.fullyQualifiedMethod)! } -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) private func assertTestSpanComponents( forMethod method: MethodDescriptor, tracer: TestTracer, @@ -1279,7 +1279,7 @@ private func assertTestSpanComponents( assertErrors(span.errors) } -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) private func assertStreamContentsEqual( _ array: [T], _ stream: any AsyncSequence @@ -1291,7 +1291,7 @@ private func assertStreamContentsEqual( #expect(streamElements == array) } -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) private func assertStreamContentsEqual( _ array: [T], _ stream: any AsyncSequence diff --git a/Tests/GRPCOTelTracingInterceptorsTests/TracingTestsUtilities.swift b/Tests/GRPCOTelTracingInterceptorsTests/TracingTestsUtilities.swift index 4344fe2..8d465c5 100644 --- a/Tests/GRPCOTelTracingInterceptorsTests/TracingTestsUtilities.swift +++ b/Tests/GRPCOTelTracingInterceptorsTests/TracingTestsUtilities.swift @@ -18,7 +18,7 @@ import GRPCCore import Synchronization import Tracing -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) final class TestTracer: Tracer { typealias Span = TestSpan @@ -72,7 +72,7 @@ final class TestTracer: Tracer { } } -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) final class TestSpan: Span, Sendable { private struct State { var context: ServiceContextModule.ServiceContext diff --git a/Tests/GRPCReflectionServiceTests/GRPCReflectionServiceTests.swift b/Tests/GRPCReflectionServiceTests/GRPCReflectionServiceTests.swift index ba159b4..34484f0 100644 --- a/Tests/GRPCReflectionServiceTests/GRPCReflectionServiceTests.swift +++ b/Tests/GRPCReflectionServiceTests/GRPCReflectionServiceTests.swift @@ -23,7 +23,7 @@ import Testing @Suite("gRPC Reflection Service Tests") struct GRPCReflectionServiceTests { - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func withReflectionClient( descriptorSetPaths: [String] = Bundle.module.pathsForDescriptorSets, execute body: (ReflectionClient) async throws -> Void @@ -40,7 +40,7 @@ struct GRPCReflectionServiceTests { } @Test("List services") - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func listServices() async throws { try await self.withReflectionClient { reflection in let services = try await reflection.listServices() @@ -59,7 +59,7 @@ struct GRPCReflectionServiceTests { "grpc/health/v1/health.proto", ] ) - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func fileByFileName(fileName: String) async throws { try await self.withReflectionClient { reflection in let descriptors = try await reflection.fileByFileName(fileName) @@ -69,7 +69,7 @@ struct GRPCReflectionServiceTests { } @Test("File by file name (doesn't exist)") - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func testFileByNonExistentFileName() async throws { try await self.withReflectionClient { reflection in await #expect { @@ -93,7 +93,7 @@ struct GRPCReflectionServiceTests { ("grpc/reflection/v1/reflection.proto", "grpc.reflection.v1.ErrorResponse"), ] as [(String, String)] ) - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func fileContainingSymbol(fileName: String, symbol: String) async throws { try await self.withReflectionClient { reflection in let descriptors = try await reflection.fileContainingSymbol(symbol) @@ -103,7 +103,7 @@ struct GRPCReflectionServiceTests { } @Test("File containing symbol includes dependencies") - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func fileContainingSymbolWithDependency() async throws { try await self.withReflectionClient { reflection in let descriptors = try await reflection.fileContainingSymbol(".MessageWithDependency") @@ -113,7 +113,7 @@ struct GRPCReflectionServiceTests { } @Test("File containing symbol (doesn't exist)") - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func testFileContainingNonExistentSymbol() async throws { try await self.withReflectionClient { reflection in await #expect { @@ -128,7 +128,7 @@ struct GRPCReflectionServiceTests { } @Test("File containing extension") - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func testFileContainingExtension() async throws { try await self.withReflectionClient { reflection in let descriptors = try await reflection.fileContainingExtension(number: 100, in: "BaseMessage") @@ -138,7 +138,7 @@ struct GRPCReflectionServiceTests { } @Test("File containing extension (doesn't exist)") - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func testFileContainingNonExistentExtension() async throws { try await self.withReflectionClient { reflection in await #expect { diff --git a/Tests/GRPCReflectionServiceTests/ReflectionClient.swift b/Tests/GRPCReflectionServiceTests/ReflectionClient.swift index 017289d..045acc2 100644 --- a/Tests/GRPCReflectionServiceTests/ReflectionClient.swift +++ b/Tests/GRPCReflectionServiceTests/ReflectionClient.swift @@ -19,7 +19,7 @@ import GRPCInProcessTransport import GRPCReflectionService import SwiftProtobuf -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) struct ReflectionClient: Sendable { private typealias Request = Grpc_Reflection_V1_ServerReflectionRequest private let stub: Grpc_Reflection_V1_ServerReflection.Client diff --git a/Tests/GRPCServiceLifecycleTests/ServiceLifecycleConformanceTests.swift b/Tests/GRPCServiceLifecycleTests/ServiceLifecycleConformanceTests.swift index bd4941b..0b7bae5 100644 --- a/Tests/GRPCServiceLifecycleTests/ServiceLifecycleConformanceTests.swift +++ b/Tests/GRPCServiceLifecycleTests/ServiceLifecycleConformanceTests.swift @@ -23,7 +23,7 @@ import Testing @Suite("gRPC ServiceLifecycle/Service conformance tests") struct ServiceLifecycleConformanceTests { @Test("Client respects graceful shutdown") - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func clientGracefulShutdown() async throws { let inProcess = InProcessTransport() try await testGracefulShutdown { trigger in @@ -42,7 +42,7 @@ struct ServiceLifecycleConformanceTests { } @Test("Server respects graceful shutdown") - @available(gRPCSwiftExtras 1.0, *) + @available(gRPCSwiftExtras 2.0, *) func serverGracefulShutdown() async throws { let inProcess = InProcessTransport() try await testGracefulShutdown { trigger in diff --git a/Tests/InProcessInteropTests/InProcessInteroperabilityTests.swift b/Tests/InProcessInteropTests/InProcessInteroperabilityTests.swift index 2df207c..7fbcb74 100644 --- a/Tests/InProcessInteropTests/InProcessInteroperabilityTests.swift +++ b/Tests/InProcessInteropTests/InProcessInteroperabilityTests.swift @@ -19,7 +19,7 @@ import GRPCInProcessTransport import GRPCInteropTests import XCTest -@available(gRPCSwiftExtras 1.0, *) +@available(gRPCSwiftExtras 2.0, *) final class InProcessInteroperabilityTests: XCTestCase { func runInProcessTransport( interopTestCase: InteroperabilityTestCase diff --git a/dev/protos/generate.sh b/dev/protos/generate.sh index 5cdfe38..9caa2ff 100755 --- a/dev/protos/generate.sh +++ b/dev/protos/generate.sh @@ -21,12 +21,12 @@ protoc=$(which protoc) # Build the protoc plugins. swift build -c release --product protoc-gen-swift -swift build -c release --product protoc-gen-grpc-swift +swift build -c release --product protoc-gen-grpc-swift-2 # Grab the plugin paths. bin_path=$(swift build -c release --show-bin-path) protoc_gen_swift="$bin_path/protoc-gen-swift" -protoc_generate_grpc_swift="$bin_path/protoc-gen-grpc-swift" +protoc_generate_grpc_swift="$bin_path/protoc-gen-grpc-swift-2" # Generates gRPC by invoking protoc with the gRPC Swift plugin. # Parameters: @@ -36,10 +36,10 @@ protoc_generate_grpc_swift="$bin_path/protoc-gen-grpc-swift" # - $4 onwards: options to forward to the plugin function generate_grpc { local proto=$1 - local args=("--plugin=$protoc_generate_grpc_swift" "--proto_path=${2}" "--grpc-swift_out=${3}") + local args=("--plugin=$protoc_generate_grpc_swift" "--proto_path=${2}" "--grpc-swift-2_out=${3}") for option in "${@:4}"; do - args+=("--grpc-swift_opt=$option") + args+=("--grpc-swift-2_opt=$option") done invoke_protoc "${args[@]}" "$proto"