Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ let products: [Product] = [
let dependencies: [Package.Dependency] = [
.package(
url: "https://github.com/grpc/grpc-swift.git",
exact: "2.0.0-beta.2"
branch: "main"
),
.package(
url: "https://github.com/grpc/grpc-swift-protobuf.git",
exact: "1.0.0-beta.2"
branch: "main"
),
.package(
url: "https://github.com/apple/swift-protobuf.git",
Expand Down
8 changes: 4 additions & 4 deletions Sources/GRPCHealthService/Generated/health.grpc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ extension Grpc_Health_V1_Health {

// Default implementation of 'registerMethods(with:)'.
extension Grpc_Health_V1_Health.StreamingServiceProtocol {
package func registerMethods(with router: inout GRPCCore.RPCRouter) {
package func registerMethods<Transport>(with router: inout GRPCCore.RPCRouter<Transport>) where Transport: GRPCCore.ServerTransport {
router.registerHandler(
forMethod: Grpc_Health_V1_Health.Method.Check.descriptor,
deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Health_V1_HealthCheckRequest>(),
Expand Down Expand Up @@ -477,14 +477,14 @@ extension Grpc_Health_V1_Health {
/// > Health is gRPC's mechanism for checking whether a server is able to handle
/// > RPCs. Its semantics are documented in
/// > https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
package struct Client: ClientProtocol {
private let client: GRPCCore.GRPCClient
package struct Client<Transport>: ClientProtocol where Transport: GRPCCore.ClientTransport {
private let client: GRPCCore.GRPCClient<Transport>

/// Creates a new client wrapping the provided `GRPCCore.GRPCClient`.
///
/// - Parameters:
/// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service.
package init(wrapping client: GRPCCore.GRPCClient) {
package init(wrapping client: GRPCCore.GRPCClient<Transport>) {
self.client = client
}

Expand Down
4 changes: 3 additions & 1 deletion Sources/GRPCHealthService/HealthService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public struct HealthService: Sendable, RegistrableRPCService {
self.provider = HealthService.Provider(healthService: healthService)
}

public func registerMethods(with router: inout RPCRouter) {
public func registerMethods<Transport>(
with router: inout RPCRouter<Transport>
) where Transport: ServerTransport {
self.service.registerMethods(with: &router)
}
}
Expand Down
24 changes: 24 additions & 0 deletions Sources/GRPCInteropTests/Generated/empty.grpc.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2015 gRPC authors.
//
// 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.

// DO NOT EDIT.
// swift-format-ignore-file
//
// Generated by the gRPC Swift generator plugin for the protocol buffer compiler.
// Source: src/proto/grpc/testing/empty.proto
//
// For information on using the generated types, please see the documentation:
// https://github.com/grpc/grpc-swift

// This file contained no services.
8 changes: 4 additions & 4 deletions Sources/GRPCInteropTests/Generated/empty_service.grpc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ extension Grpc_Testing_EmptyService {

// Default implementation of 'registerMethods(with:)'.
extension Grpc_Testing_EmptyService.StreamingServiceProtocol {
public func registerMethods(with router: inout GRPCCore.RPCRouter) {}
public func registerMethods<Transport>(with router: inout GRPCCore.RPCRouter<Transport>) where Transport: GRPCCore.ServerTransport {}
}

// Default implementation of streaming methods from 'StreamingServiceProtocol'.
Expand Down Expand Up @@ -126,14 +126,14 @@ extension Grpc_Testing_EmptyService {
/// >
/// > A service that has zero methods.
/// > See https://github.com/grpc/grpc/issues/15574
public struct Client: ClientProtocol {
private let client: GRPCCore.GRPCClient
public struct Client<Transport>: ClientProtocol where Transport: GRPCCore.ClientTransport {
private let client: GRPCCore.GRPCClient<Transport>

/// Creates a new client wrapping the provided `GRPCCore.GRPCClient`.
///
/// - Parameters:
/// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service.
public init(wrapping client: GRPCCore.GRPCClient) {
public init(wrapping client: GRPCCore.GRPCClient<Transport>) {
self.client = client
}
}
Expand Down
26 changes: 26 additions & 0 deletions Sources/GRPCInteropTests/Generated/messages.grpc.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2015-2016 gRPC authors.
//
// 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.

// Message definitions to be used by integration test service definitions.

// DO NOT EDIT.
// swift-format-ignore-file
//
// Generated by the gRPC Swift generator plugin for the protocol buffer compiler.
// Source: src/proto/grpc/testing/messages.proto
//
// For information on using the generated types, please see the documentation:
// https://github.com/grpc/grpc-swift

// This file contained no services.
24 changes: 12 additions & 12 deletions Sources/GRPCInteropTests/Generated/test.grpc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ extension Grpc_Testing_TestService {

// Default implementation of 'registerMethods(with:)'.
extension Grpc_Testing_TestService.StreamingServiceProtocol {
public func registerMethods(with router: inout GRPCCore.RPCRouter) {
public func registerMethods<Transport>(with router: inout GRPCCore.RPCRouter<Transport>) where Transport: GRPCCore.ServerTransport {
router.registerHandler(
forMethod: Grpc_Testing_TestService.Method.EmptyCall.descriptor,
deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Testing_Empty>(),
Expand Down Expand Up @@ -1162,14 +1162,14 @@ extension Grpc_Testing_TestService {
/// >
/// > A simple service to test the various types of RPCs and experiment with
/// > performance with various types of payload.
public struct Client: ClientProtocol {
private let client: GRPCCore.GRPCClient
public struct Client<Transport>: ClientProtocol where Transport: GRPCCore.ClientTransport {
private let client: GRPCCore.GRPCClient<Transport>

/// Creates a new client wrapping the provided `GRPCCore.GRPCClient`.
///
/// - Parameters:
/// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service.
public init(wrapping client: GRPCCore.GRPCClient) {
public init(wrapping client: GRPCCore.GRPCClient<Transport>) {
self.client = client
}

Expand Down Expand Up @@ -2099,7 +2099,7 @@ extension Grpc_Testing_UnimplementedService {

// Default implementation of 'registerMethods(with:)'.
extension Grpc_Testing_UnimplementedService.StreamingServiceProtocol {
public func registerMethods(with router: inout GRPCCore.RPCRouter) {
public func registerMethods<Transport>(with router: inout GRPCCore.RPCRouter<Transport>) where Transport: GRPCCore.ServerTransport {
router.registerHandler(
forMethod: Grpc_Testing_UnimplementedService.Method.UnimplementedCall.descriptor,
deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Testing_Empty>(),
Expand Down Expand Up @@ -2191,14 +2191,14 @@ extension Grpc_Testing_UnimplementedService {
/// >
/// > A simple service NOT implemented at servers so clients can test for
/// > that case.
public struct Client: ClientProtocol {
private let client: GRPCCore.GRPCClient
public struct Client<Transport>: ClientProtocol where Transport: GRPCCore.ClientTransport {
private let client: GRPCCore.GRPCClient<Transport>

/// Creates a new client wrapping the provided `GRPCCore.GRPCClient`.
///
/// - Parameters:
/// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service.
public init(wrapping client: GRPCCore.GRPCClient) {
public init(wrapping client: GRPCCore.GRPCClient<Transport>) {
self.client = client
}

Expand Down Expand Up @@ -2481,7 +2481,7 @@ extension Grpc_Testing_ReconnectService {

// Default implementation of 'registerMethods(with:)'.
extension Grpc_Testing_ReconnectService.StreamingServiceProtocol {
public func registerMethods(with router: inout GRPCCore.RPCRouter) {
public func registerMethods<Transport>(with router: inout GRPCCore.RPCRouter<Transport>) where Transport: GRPCCore.ServerTransport {
router.registerHandler(
forMethod: Grpc_Testing_ReconnectService.Method.Start.descriptor,
deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Testing_ReconnectParams>(),
Expand Down Expand Up @@ -2621,14 +2621,14 @@ extension Grpc_Testing_ReconnectService {
/// > Source IDL Documentation:
/// >
/// > A service used to control reconnect server.
public struct Client: ClientProtocol {
private let client: GRPCCore.GRPCClient
public struct Client<Transport>: ClientProtocol where Transport: GRPCCore.ClientTransport {
private let client: GRPCCore.GRPCClient<Transport>

/// Creates a new client wrapping the provided `GRPCCore.GRPCClient`.
///
/// - Parameters:
/// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service.
public init(wrapping client: GRPCCore.GRPCClient) {
public init(wrapping client: GRPCCore.GRPCClient<Transport>) {
self.client = client
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/GRPCInteropTests/InteroperabilityTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public protocol InteroperabilityTest {
///
/// - Parameter client: The client to use for the test.
/// - Throws: Any exception may be thrown to indicate an unsuccessful test.
func run(client: GRPCClient) async throws
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws
}

/// Test cases as listed by the [gRPC interoperability test description specification]
Expand Down
28 changes: 14 additions & 14 deletions Sources/GRPCInteropTests/InteroperabilityTestCases.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private import struct Foundation.Data
/// - call was successful
/// - response is non-null
struct EmptyUnary: InteroperabilityTest {
func run(client: GRPCClient) async throws {
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)
try await testServiceClient.emptyCall(
request: ClientRequest(message: Grpc_Testing_Empty())
Expand Down Expand Up @@ -70,7 +70,7 @@ struct EmptyUnary: InteroperabilityTest {
/// - clients are free to assert that the response payload body contents are zero and comparing
/// the entire response message against a golden response
struct LargeUnary: InteroperabilityTest {
func run(client: GRPCClient) async throws {
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)
let request = Grpc_Testing_SimpleRequest.with { request in
request.responseSize = 314_159
Expand Down Expand Up @@ -145,7 +145,7 @@ struct LargeUnary: InteroperabilityTest {
/// - Clients are free to assert that the response payload body contents are zeros and comparing the
/// entire response message against a golden response.
class ClientCompressedUnary: InteroperabilityTest {
func run(client: GRPCClient) async throws {
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)
let compressedRequest = Grpc_Testing_SimpleRequest.with { request in
request.expectCompressed = .with { $0.value = true }
Expand Down Expand Up @@ -253,7 +253,7 @@ class ClientCompressedUnary: InteroperabilityTest {
/// - clients are free to assert that the response payload body contents are zero and comparing the
/// entire response message against a golden response
class ServerCompressedUnary: InteroperabilityTest {
func run(client: GRPCClient) async throws {
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)

let compressedRequest = Grpc_Testing_SimpleRequest.with { request in
Expand Down Expand Up @@ -342,7 +342,7 @@ class ServerCompressedUnary: InteroperabilityTest {
/// - call was successful
/// - response aggregated_payload_size is 74922
struct ClientStreaming: InteroperabilityTest {
func run(client: GRPCClient) async throws {
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)
let request = StreamingClientRequest { writer in
for bytes in [27182, 8, 1828, 45904] {
Expand Down Expand Up @@ -392,7 +392,7 @@ struct ClientStreaming: InteroperabilityTest {
/// - clients are free to assert that the response payload body contents are zero and
/// comparing the entire response messages against golden responses
struct ServerStreaming: InteroperabilityTest {
func run(client: GRPCClient) async throws {
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)
let responseSizes = [31415, 9, 2653, 58979]
let request = Grpc_Testing_StreamingOutputCallRequest.with { request in
Expand Down Expand Up @@ -467,7 +467,7 @@ struct ServerStreaming: InteroperabilityTest {
/// - clients are free to assert that the response payload body contents are zero and comparing the
/// entire response messages against golden responses
class ServerCompressedStreaming: InteroperabilityTest {
func run(client: GRPCClient) async throws {
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)
let request: Grpc_Testing_StreamingOutputCallRequest = .with { request in
request.responseParameters = [
Expand Down Expand Up @@ -579,7 +579,7 @@ class ServerCompressedStreaming: InteroperabilityTest {
/// - clients are free to assert that the response payload body contents are zero and
/// comparing the entire response messages against golden responses
struct PingPong: InteroperabilityTest {
func run(client: GRPCClient) async throws {
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)
let ids = AsyncStream.makeStream(of: Int.self)

Expand Down Expand Up @@ -645,7 +645,7 @@ struct PingPong: InteroperabilityTest {
/// - call was successful
/// - exactly zero responses
struct EmptyStream: InteroperabilityTest {
func run(client: GRPCClient) async throws {
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)
let request = StreamingClientRequest<Grpc_Testing_StreamingOutputCallRequest> { _ in }

Expand Down Expand Up @@ -716,7 +716,7 @@ struct CustomMetadata: InteroperabilityTest {
try assertEqual(Array(values), [.binary(self.trailingMetadataValue)])
}

func run(client: GRPCClient) async throws {
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)

let unaryRequest = Grpc_Testing_SimpleRequest.with { request in
Expand Down Expand Up @@ -823,7 +823,7 @@ struct StatusCodeAndMessage: InteroperabilityTest {
let expectedCode = 2
let expectedMessage = "test status message"

func run(client: GRPCClient) async throws {
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)

let message = Grpc_Testing_SimpleRequest.with {
Expand Down Expand Up @@ -897,7 +897,7 @@ struct StatusCodeAndMessage: InteroperabilityTest {
/// - received status message is the same as the sent message for Procedure step 1, including all
/// whitespace characters
struct SpecialStatusMessage: InteroperabilityTest {
func run(client: GRPCClient) async throws {
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)

let responseMessage = "\t\ntest with whitespace\r\nand Unicode BMP ☺ and non-BMP 😈\t\n"
Expand Down Expand Up @@ -939,7 +939,7 @@ struct SpecialStatusMessage: InteroperabilityTest {
/// Client asserts:
/// - received status code is 12 (UNIMPLEMENTED)
struct UnimplementedMethod: InteroperabilityTest {
func run(client: GRPCClient) async throws {
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)
try await testServiceClient.unimplementedCall(
request: ClientRequest(message: Grpc_Testing_Empty())
Expand Down Expand Up @@ -971,7 +971,7 @@ struct UnimplementedMethod: InteroperabilityTest {
/// Client asserts:
/// - received status code is 12 (UNIMPLEMENTED)
struct UnimplementedService: InteroperabilityTest {
func run(client: GRPCClient) async throws {
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
let unimplementedServiceClient = Grpc_Testing_UnimplementedService.Client(wrapping: client)
try await unimplementedServiceClient.unimplementedCall(
request: ClientRequest(message: Grpc_Testing_Empty())
Expand Down
8 changes: 4 additions & 4 deletions Sources/GRPCReflectionService/Generated/reflection.grpc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ extension Grpc_Reflection_V1_ServerReflection {

// Default implementation of 'registerMethods(with:)'.
extension Grpc_Reflection_V1_ServerReflection.StreamingServiceProtocol {
package func registerMethods(with router: inout GRPCCore.RPCRouter) {
package func registerMethods<Transport>(with router: inout GRPCCore.RPCRouter<Transport>) where Transport: GRPCCore.ServerTransport {
router.registerHandler(
forMethod: Grpc_Reflection_V1_ServerReflection.Method.ServerReflectionInfo.descriptor,
deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Reflection_V1_ServerReflectionRequest>(),
Expand Down Expand Up @@ -232,14 +232,14 @@ extension Grpc_Reflection_V1_ServerReflection {
/// The ``Client`` provides an implementation of ``ClientProtocol`` which wraps
/// a `GRPCCore.GRPCCClient`. The underlying `GRPCClient` provides the long-lived
/// means of communication with the remote peer.
package struct Client: ClientProtocol {
private let client: GRPCCore.GRPCClient
package struct Client<Transport>: ClientProtocol where Transport: GRPCCore.ClientTransport {
private let client: GRPCCore.GRPCClient<Transport>

/// Creates a new client wrapping the provided `GRPCCore.GRPCClient`.
///
/// - Parameters:
/// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service.
package init(wrapping client: GRPCCore.GRPCClient) {
package init(wrapping client: GRPCCore.GRPCClient<Transport>) {
self.client = client
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public struct ReflectionService: Sendable {
}

extension ReflectionService: RegistrableRPCService {
public func registerMethods(with router: inout RPCRouter) {
public func registerMethods<Transport>(
with router: inout RPCRouter<Transport>
) where Transport: ServerTransport {
self.service.registerMethods(with: &router)
}
}
Expand Down
5 changes: 4 additions & 1 deletion Tests/GRPCHealthServiceTests/HealthTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import XCTest

final class HealthTests: XCTestCase {
private func withHealthClient(
_ body: @Sendable (Grpc_Health_V1_Health.Client, HealthService.Provider) async throws -> Void
_ body: @Sendable (
Grpc_Health_V1_Health.Client<InProcessTransport.Client>,
Health.Provider
) async throws -> Void
) async throws {
let health = HealthService()
let inProcess = InProcessTransport()
Expand Down
Loading
Loading