Skip to content

Commit adc18c3

Browse files
authored
Add deprecation warnings (#2248)
Motivation: v2 has moved to a new repo, grpc-swift-2. That's not all that discoverable. Modifications: - Deprecate commonly used high-level types with a link to a forums post explaining the move. Result: Users are notified about the move
1 parent 36e1ad1 commit adc18c3

File tree

12 files changed

+47
-34
lines changed

12 files changed

+47
-34
lines changed

.github/workflows/pull_request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ jobs:
2222
with:
2323
linux_5_9_enabled: false
2424
linux_5_10_enabled: false
25-
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -warnings-as-errors -Xswiftc -require-explicit-availability"
26-
linux_6_1_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -warnings-as-errors -Xswiftc -require-explicit-availability"
25+
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-availability"
26+
linux_6_1_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-availability"
2727
linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-availability"
2828
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-availability"
2929

Sources/GRPCCore/Call/Server/RegistrableRPCService.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
/// ``RPCRouter/registerHandler(forMethod:deserializer:serializer:handler:)`` for each method
2424
/// you want to register with the router.
2525
@available(gRPCSwift 2.0, *)
26+
@available(*, deprecated, message: "See https://forums.swift.org/t/80177")
2627
public protocol RegistrableRPCService: Sendable {
2728
/// Registers methods to server with the provided ``RPCRouter``.
2829
///

Sources/GRPCCore/GRPCClient.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ private import Synchronization
5555
/// additional resources that need their lifecycles managed you should consider using [Swift Service
5656
/// Lifecycle](https://github.com/swift-server/swift-service-lifecycle).
5757
@available(gRPCSwift 2.0, *)
58+
@available(*, deprecated, message: "See https://forums.swift.org/t/80177")
5859
public final class GRPCClient<Transport: ClientTransport>: Sendable {
5960
/// The transport which provides a bidirectional communication channel with the server.
6061
private let transport: Transport
@@ -399,6 +400,7 @@ public final class GRPCClient<Transport: ClientTransport>: Sendable {
399400
/// - handleClient: A closure which is called with the client. When the closure returns, the
400401
/// client is shutdown gracefully.
401402
@available(gRPCSwift 2.0, *)
403+
@available(*, deprecated, message: "See https://forums.swift.org/t/80177")
402404
public func withGRPCClient<Transport: ClientTransport, Result: Sendable>(
403405
transport: Transport,
404406
interceptors: [any ClientInterceptor] = [],
@@ -428,6 +430,7 @@ public func withGRPCClient<Transport: ClientTransport, Result: Sendable>(
428430
/// client is shutdown gracefully.
429431
/// - Returns: The result of the `handleClient` closure.
430432
@available(gRPCSwift 2.0, *)
433+
@available(*, deprecated, message: "See https://forums.swift.org/t/80177")
431434
public func withGRPCClient<Transport: ClientTransport, Result: Sendable>(
432435
transport: Transport,
433436
interceptorPipeline: [ConditionalInterceptor<any ClientInterceptor>],

Sources/GRPCCore/GRPCServer.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ private import Synchronization
7676
/// Lifecycle](https://github.com/swift-server/swift-service-lifecycle) and the
7777
/// `GRPCServiceLifecycle` module provided by [gRPC Swift Extras](https://github.com/grpc/grpc-swift-extras).
7878
@available(gRPCSwift 2.0, *)
79+
@available(*, deprecated, message: "See https://forums.swift.org/t/80177")
7980
public final class GRPCServer<Transport: ServerTransport>: Sendable {
8081
typealias Stream = RPCStream<Transport.Inbound, Transport.Outbound>
8182

@@ -259,6 +260,7 @@ public final class GRPCServer<Transport: ServerTransport>: Sendable {
259260
/// server is shutdown gracefully.
260261
/// - Returns: The result of the `handleServer` closure.
261262
@available(gRPCSwift 2.0, *)
263+
@available(*, deprecated, message: "See https://forums.swift.org/t/80177")
262264
public func withGRPCServer<Transport: ServerTransport, Result: Sendable>(
263265
transport: Transport,
264266
services: [any RegistrableRPCService],
@@ -291,6 +293,7 @@ public func withGRPCServer<Transport: ServerTransport, Result: Sendable>(
291293
/// server is shutdown gracefully.
292294
/// - Returns: The result of the `handleServer` closure.
293295
@available(gRPCSwift 2.0, *)
296+
@available(*, deprecated, message: "See https://forums.swift.org/t/80177")
294297
public func withGRPCServer<Transport: ServerTransport, Result: Sendable>(
295298
transport: Transport,
296299
services: [any RegistrableRPCService],

Sources/GRPCCore/Metadata.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
/// the "-bin" suffix may have string values (rather than binary). These are deserialized automatically when
8181
/// using ``subscript(binaryValues:)``.
8282
@available(gRPCSwift 2.0, *)
83+
@available(*, deprecated, message: "See https://forums.swift.org/t/80177")
8384
public struct Metadata: Sendable, Hashable {
8485

8586
/// A metadata value. It can either be a simple string, or binary data.

Sources/GRPCCore/Transport/ClientTransport.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
/// transport built on top of SwiftNIO in the https://github.com/grpc/grpc-swift-nio-transport
2727
/// package.
2828
@available(gRPCSwift 2.0, *)
29+
@available(*, deprecated, message: "See https://forums.swift.org/t/80177")
2930
public protocol ClientTransport<Bytes>: Sendable {
3031
/// The bag-of-bytes type used by the transport.
3132
associatedtype Bytes: GRPCContiguousBytes & Sendable

Sources/GRPCCore/Transport/ServerTransport.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
/// transport built on top of SwiftNIO in the https://github.com/grpc/grpc-swift-nio-transport
2424
/// package.
2525
@available(gRPCSwift 2.0, *)
26+
@available(*, deprecated, message: "See https://forums.swift.org/t/80177")
2627
public protocol ServerTransport<Bytes>: Sendable {
2728
/// The bag-of-bytes type used by the transport.
2829
associatedtype Bytes: GRPCContiguousBytes & Sendable

Sources/GRPCInProcessTransport/InProcessTransport.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
public import GRPCCore
1818

1919
@available(gRPCSwift 2.0, *)
20+
@available(*, deprecated, message: "See https://forums.swift.org/t/80177")
2021
public struct InProcessTransport: Sendable {
2122
public let server: Self.Server
2223
public let client: Self.Client

Tests/GRPCCoreTests/Configuration/Generated/rls.pb.swift

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,16 @@ fileprivate let _protobuf_package = "grpc.lookup.v1"
134134

135135
extension Grpc_Lookup_V1_RouteLookupRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
136136
static let protoMessageName: String = _protobuf_package + ".RouteLookupRequest"
137-
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
138-
3: .standard(proto: "target_type"),
139-
5: .same(proto: "reason"),
140-
6: .standard(proto: "stale_header_data"),
141-
4: .standard(proto: "key_map"),
142-
7: .same(proto: "extensions"),
143-
]
137+
static let _protobuf_nameMap = SwiftProtobuf._NameMap(
138+
reservedNames: ["server", "path"],
139+
reservedRanges: [1..<3],
140+
numberNameMappings: [
141+
3: .standard(proto: "target_type"),
142+
5: .same(proto: "reason"),
143+
6: .standard(proto: "stale_header_data"),
144+
4: .standard(proto: "key_map"),
145+
7: .same(proto: "extensions"),
146+
])
144147

145148
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
146149
while let fieldNumber = try decoder.nextFieldNumber() {
@@ -198,11 +201,14 @@ extension Grpc_Lookup_V1_RouteLookupRequest.Reason: SwiftProtobuf._ProtoNameProv
198201

199202
extension Grpc_Lookup_V1_RouteLookupResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
200203
static let protoMessageName: String = _protobuf_package + ".RouteLookupResponse"
201-
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
202-
3: .same(proto: "targets"),
203-
2: .standard(proto: "header_data"),
204-
4: .same(proto: "extensions"),
205-
]
204+
static let _protobuf_nameMap = SwiftProtobuf._NameMap(
205+
reservedNames: ["target"],
206+
reservedRanges: [1..<2],
207+
numberNameMappings: [
208+
3: .same(proto: "targets"),
209+
2: .standard(proto: "header_data"),
210+
4: .same(proto: "extensions"),
211+
])
206212

207213
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
208214
while let fieldNumber = try decoder.nextFieldNumber() {

Tests/GRPCCoreTests/Configuration/Generated/rls_config.pb.swift

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -587,17 +587,20 @@ extension Grpc_Lookup_V1_HttpKeyBuilder: SwiftProtobuf.Message, SwiftProtobuf._M
587587

588588
extension Grpc_Lookup_V1_RouteLookupConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
589589
static let protoMessageName: String = _protobuf_package + ".RouteLookupConfig"
590-
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
591-
1: .standard(proto: "http_keybuilders"),
592-
2: .standard(proto: "grpc_keybuilders"),
593-
3: .standard(proto: "lookup_service"),
594-
4: .standard(proto: "lookup_service_timeout"),
595-
5: .standard(proto: "max_age"),
596-
6: .standard(proto: "stale_age"),
597-
7: .standard(proto: "cache_size_bytes"),
598-
8: .standard(proto: "valid_targets"),
599-
9: .standard(proto: "default_target"),
600-
]
590+
static let _protobuf_nameMap = SwiftProtobuf._NameMap(
591+
reservedNames: ["request_processing_strategy"],
592+
reservedRanges: [10..<11],
593+
numberNameMappings: [
594+
1: .standard(proto: "http_keybuilders"),
595+
2: .standard(proto: "grpc_keybuilders"),
596+
3: .standard(proto: "lookup_service"),
597+
4: .standard(proto: "lookup_service_timeout"),
598+
5: .standard(proto: "max_age"),
599+
6: .standard(proto: "stale_age"),
600+
7: .standard(proto: "cache_size_bytes"),
601+
8: .standard(proto: "valid_targets"),
602+
9: .standard(proto: "default_target"),
603+
])
601604

602605
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
603606
while let fieldNumber = try decoder.nextFieldNumber() {

Tests/GRPCCoreTests/Configuration/Generated/service_config.pb.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,15 +2549,11 @@ extension Grpc_ServiceConfig_RlsLoadBalancingPolicyConfig: SwiftProtobuf.Message
25492549
var _childPolicy: [Grpc_ServiceConfig_LoadBalancingConfig] = []
25502550
var _childPolicyConfigTargetFieldName: String = String()
25512551

2552-
#if swift(>=5.10)
25532552
// This property is used as the initial default value for new instances of the type.
25542553
// The type itself is protecting the reference to its storage via CoW semantics.
25552554
// This will force a copy to be made of this reference when the first mutation occurs;
25562555
// hence, it is safe to mark this as `nonisolated(unsafe)`.
25572556
static nonisolated(unsafe) let defaultInstance = _StorageClass()
2558-
#else
2559-
static let defaultInstance = _StorageClass()
2560-
#endif
25612557

25622558
private init() {}
25632559

@@ -3692,15 +3688,11 @@ extension Grpc_ServiceConfig_XdsClusterResolverLoadBalancingPolicyConfig.Discove
36923688
var _overrideHostStatus: [Grpc_ServiceConfig_OverrideHostLoadBalancingPolicyConfig.HealthStatus] = []
36933689
var _telemetryLabels: Dictionary<String,String> = [:]
36943690

3695-
#if swift(>=5.10)
36963691
// This property is used as the initial default value for new instances of the type.
36973692
// The type itself is protecting the reference to its storage via CoW semantics.
36983693
// This will force a copy to be made of this reference when the first mutation occurs;
36993694
// hence, it is safe to mark this as `nonisolated(unsafe)`.
37003695
static nonisolated(unsafe) let defaultInstance = _StorageClass()
3701-
#else
3702-
static let defaultInstance = _StorageClass()
3703-
#endif
37043696

37053697
private init() {}
37063698

dev/protos/generate.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ protoc=$(which protoc)
2121

2222
# Checkout and build the plugins.
2323
build_dir=$(mktemp -d)
24-
git clone https://github.com/grpc/grpc-swift-protobuf --depth 1 "$build_dir"
24+
git clone -b 1.3.0 https://github.com/grpc/grpc-swift-protobuf --depth 1 "$build_dir"
25+
2526
swift build --package-path "$build_dir" --product protoc-gen-swift
2627
swift build --package-path "$build_dir" --product protoc-gen-grpc-swift
2728

0 commit comments

Comments
 (0)