Skip to content

Commit e933e79

Browse files
authored
Bump minimum protobuf version to 1.19.0 (#1376)
Motivation: swift-protobuf added `Sendable` conformance to generated messages in the 1.19.0 release. Modifications: - Bump minimum protobuf version - Regenerate examples and interop tests Result: Protobuf messages are `Sendable`
1 parent d393fa1 commit e933e79

File tree

6 files changed

+153
-1
lines changed

6 files changed

+153
-1
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ let packageDependencies: [Package.Dependency] = [
4949
.package(
5050
name: "SwiftProtobuf",
5151
url: "https://github.com/apple/swift-protobuf.git",
52-
from: "1.9.0"
52+
from: "1.19.0"
5353
),
5454
.package(
5555
url: "https://github.com/apple/swift-log.git",

Sources/Examples/Echo/Model/echo.pb.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public struct Echo_EchoResponse {
6060
public init() {}
6161
}
6262

63+
#if swift(>=5.5) && canImport(_Concurrency)
64+
extension Echo_EchoRequest: @unchecked Sendable {}
65+
extension Echo_EchoResponse: @unchecked Sendable {}
66+
#endif // swift(>=5.5) && canImport(_Concurrency)
67+
6368
// MARK: - Code below here is support for the SwiftProtobuf runtime.
6469

6570
fileprivate let _protobuf_package = "echo"

Sources/Examples/HelloWorld/Model/helloworld.grpc.swift

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,76 @@ public final class Helloworld_GreeterClient: Helloworld_GreeterClientProtocol {
8484
}
8585
}
8686

87+
#if compiler(>=5.5.2) && canImport(_Concurrency)
88+
/// The greeting service definition.
89+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
90+
public protocol Helloworld_GreeterAsyncClientProtocol: GRPCClient {
91+
static var serviceDescriptor: GRPCServiceDescriptor { get }
92+
var interceptors: Helloworld_GreeterClientInterceptorFactoryProtocol? { get }
93+
94+
func makeSayHelloCall(
95+
_ request: Helloworld_HelloRequest,
96+
callOptions: CallOptions?
97+
) -> GRPCAsyncUnaryCall<Helloworld_HelloRequest, Helloworld_HelloReply>
98+
}
99+
100+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
101+
extension Helloworld_GreeterAsyncClientProtocol {
102+
public static var serviceDescriptor: GRPCServiceDescriptor {
103+
return Helloworld_GreeterClientMetadata.serviceDescriptor
104+
}
105+
106+
public var interceptors: Helloworld_GreeterClientInterceptorFactoryProtocol? {
107+
return nil
108+
}
109+
110+
public func makeSayHelloCall(
111+
_ request: Helloworld_HelloRequest,
112+
callOptions: CallOptions? = nil
113+
) -> GRPCAsyncUnaryCall<Helloworld_HelloRequest, Helloworld_HelloReply> {
114+
return self.makeAsyncUnaryCall(
115+
path: Helloworld_GreeterClientMetadata.Methods.sayHello.path,
116+
request: request,
117+
callOptions: callOptions ?? self.defaultCallOptions,
118+
interceptors: self.interceptors?.makeSayHelloInterceptors() ?? []
119+
)
120+
}
121+
}
122+
123+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
124+
extension Helloworld_GreeterAsyncClientProtocol {
125+
public func sayHello(
126+
_ request: Helloworld_HelloRequest,
127+
callOptions: CallOptions? = nil
128+
) async throws -> Helloworld_HelloReply {
129+
return try await self.performAsyncUnaryCall(
130+
path: Helloworld_GreeterClientMetadata.Methods.sayHello.path,
131+
request: request,
132+
callOptions: callOptions ?? self.defaultCallOptions,
133+
interceptors: self.interceptors?.makeSayHelloInterceptors() ?? []
134+
)
135+
}
136+
}
137+
138+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
139+
public struct Helloworld_GreeterAsyncClient: Helloworld_GreeterAsyncClientProtocol {
140+
public var channel: GRPCChannel
141+
public var defaultCallOptions: CallOptions
142+
public var interceptors: Helloworld_GreeterClientInterceptorFactoryProtocol?
143+
144+
public init(
145+
channel: GRPCChannel,
146+
defaultCallOptions: CallOptions = CallOptions(),
147+
interceptors: Helloworld_GreeterClientInterceptorFactoryProtocol? = nil
148+
) {
149+
self.channel = channel
150+
self.defaultCallOptions = defaultCallOptions
151+
self.interceptors = interceptors
152+
}
153+
}
154+
155+
#endif // compiler(>=5.5.2) && canImport(_Concurrency)
156+
87157
public protocol Helloworld_GreeterClientInterceptorFactoryProtocol {
88158

89159
/// - Returns: Interceptors to use when invoking 'sayHello'.
@@ -144,6 +214,58 @@ extension Helloworld_GreeterProvider {
144214
}
145215
}
146216
}
217+
#if compiler(>=5.5.2) && canImport(_Concurrency)
218+
219+
/// The greeting service definition.
220+
///
221+
/// To implement a server, implement an object which conforms to this protocol.
222+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
223+
public protocol Helloworld_GreeterAsyncProvider: CallHandlerProvider {
224+
static var serviceDescriptor: GRPCServiceDescriptor { get }
225+
var interceptors: Helloworld_GreeterServerInterceptorFactoryProtocol? { get }
226+
227+
/// Sends a greeting.
228+
@Sendable func sayHello(
229+
request: Helloworld_HelloRequest,
230+
context: GRPCAsyncServerCallContext
231+
) async throws -> Helloworld_HelloReply
232+
}
233+
234+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
235+
extension Helloworld_GreeterAsyncProvider {
236+
public static var serviceDescriptor: GRPCServiceDescriptor {
237+
return Helloworld_GreeterServerMetadata.serviceDescriptor
238+
}
239+
240+
public var serviceName: Substring {
241+
return Helloworld_GreeterServerMetadata.serviceDescriptor.fullName[...]
242+
}
243+
244+
public var interceptors: Helloworld_GreeterServerInterceptorFactoryProtocol? {
245+
return nil
246+
}
247+
248+
public func handle(
249+
method name: Substring,
250+
context: CallHandlerContext
251+
) -> GRPCServerHandlerProtocol? {
252+
switch name {
253+
case "SayHello":
254+
return GRPCAsyncServerHandler(
255+
context: context,
256+
requestDeserializer: ProtobufDeserializer<Helloworld_HelloRequest>(),
257+
responseSerializer: ProtobufSerializer<Helloworld_HelloReply>(),
258+
interceptors: self.interceptors?.makeSayHelloInterceptors() ?? [],
259+
wrapping: self.sayHello(request:context:)
260+
)
261+
262+
default:
263+
return nil
264+
}
265+
}
266+
}
267+
268+
#endif // compiler(>=5.5.2) && canImport(_Concurrency)
147269

148270
public protocol Helloworld_GreeterServerInterceptorFactoryProtocol {
149271

Sources/Examples/HelloWorld/Model/helloworld.pb.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public struct Helloworld_HelloReply {
6060
public init() {}
6161
}
6262

63+
#if swift(>=5.5) && canImport(_Concurrency)
64+
extension Helloworld_HelloRequest: @unchecked Sendable {}
65+
extension Helloworld_HelloReply: @unchecked Sendable {}
66+
#endif // swift(>=5.5) && canImport(_Concurrency)
67+
6368
// MARK: - Code below here is support for the SwiftProtobuf runtime.
6469

6570
fileprivate let _protobuf_package = "helloworld"

Sources/GRPCInteroperabilityTestModels/Generated/empty.pb.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ public struct Grpc_Testing_Empty {
5151
public init() {}
5252
}
5353

54+
#if swift(>=5.5) && canImport(_Concurrency)
55+
extension Grpc_Testing_Empty: @unchecked Sendable {}
56+
#endif // swift(>=5.5) && canImport(_Concurrency)
57+
5458
// MARK: - Code below here is support for the SwiftProtobuf runtime.
5559

5660
fileprivate let _protobuf_package = "grpc.testing"

Sources/GRPCInteroperabilityTestModels/Generated/messages.pb.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,22 @@ public struct Grpc_Testing_ReconnectInfo {
407407
public init() {}
408408
}
409409

410+
#if swift(>=5.5) && canImport(_Concurrency)
411+
extension Grpc_Testing_PayloadType: @unchecked Sendable {}
412+
extension Grpc_Testing_BoolValue: @unchecked Sendable {}
413+
extension Grpc_Testing_Payload: @unchecked Sendable {}
414+
extension Grpc_Testing_EchoStatus: @unchecked Sendable {}
415+
extension Grpc_Testing_SimpleRequest: @unchecked Sendable {}
416+
extension Grpc_Testing_SimpleResponse: @unchecked Sendable {}
417+
extension Grpc_Testing_StreamingInputCallRequest: @unchecked Sendable {}
418+
extension Grpc_Testing_StreamingInputCallResponse: @unchecked Sendable {}
419+
extension Grpc_Testing_ResponseParameters: @unchecked Sendable {}
420+
extension Grpc_Testing_StreamingOutputCallRequest: @unchecked Sendable {}
421+
extension Grpc_Testing_StreamingOutputCallResponse: @unchecked Sendable {}
422+
extension Grpc_Testing_ReconnectParams: @unchecked Sendable {}
423+
extension Grpc_Testing_ReconnectInfo: @unchecked Sendable {}
424+
#endif // swift(>=5.5) && canImport(_Concurrency)
425+
410426
// MARK: - Code below here is support for the SwiftProtobuf runtime.
411427

412428
fileprivate let _protobuf_package = "grpc.testing"

0 commit comments

Comments
 (0)