Skip to content

Commit e306943

Browse files
authored
Move to grpc-swift-2 (#112)
Motivation: To support incremental migration, v2 has moved to the 'grpc-swift-2' package. Modifications: - Update dependencies - Update generated code - Re-baseline availability Result: Easier to migrate from gRPC Swift 1 to 2
1 parent 030b9aa commit e306943

File tree

111 files changed

+366
-379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+366
-379
lines changed

IntegrationTests/grpc-interop-tests/Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ let package = Package(
2424
.package(path: "../.."),
2525
.package(
2626
url: "https://github.com/grpc/grpc-swift-protobuf",
27-
from: "1.0.0"
27+
from: "2.0.0"
2828
),
2929
.package(
3030
url: "https://github.com/grpc/grpc-swift-extras",
31-
from: "1.0.0"
31+
from: "2.0.0"
3232
),
3333
.package(
3434
url: "https://github.com/apple/swift-argument-parser",

IntegrationTests/grpc-performance-tests/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ let package = Package(
2424
.package(path: "../.."),
2525
.package(
2626
url: "https://github.com/grpc/grpc-swift-protobuf",
27-
from: "1.0.0"
27+
from: "2.0.0"
2828
),
2929
.package(
3030
url: "https://github.com/apple/swift-argument-parser",

IntegrationTests/grpc-performance-tests/Sources/Generated/grpc_testing_control.pb.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,15 +1245,11 @@ extension Grpc_Testing_ClientConfig: SwiftProtobuf.Message, SwiftProtobuf._Messa
12451245
var _medianLatencyCollectionIntervalMillis: Int32 = 0
12461246
var _clientProcesses: Int32 = 0
12471247

1248-
#if swift(>=5.10)
12491248
// This property is used as the initial default value for new instances of the type.
12501249
// The type itself is protecting the reference to its storage via CoW semantics.
12511250
// This will force a copy to be made of this reference when the first mutation occurs;
12521251
// hence, it is safe to mark this as `nonisolated(unsafe)`.
12531252
static nonisolated(unsafe) let defaultInstance = _StorageClass()
1254-
#else
1255-
static let defaultInstance = _StorageClass()
1256-
#endif
12571253

12581254
private init() {}
12591255

@@ -1871,15 +1867,11 @@ extension Grpc_Testing_Scenario: SwiftProtobuf.Message, SwiftProtobuf._MessageIm
18711867
var _benchmarkSeconds: Int32 = 0
18721868
var _spawnLocalWorkerCount: Int32 = 0
18731869

1874-
#if swift(>=5.10)
18751870
// This property is used as the initial default value for new instances of the type.
18761871
// The type itself is protecting the reference to its storage via CoW semantics.
18771872
// This will force a copy to be made of this reference when the first mutation occurs;
18781873
// hence, it is safe to mark this as `nonisolated(unsafe)`.
18791874
static nonisolated(unsafe) let defaultInstance = _StorageClass()
1880-
#else
1881-
static let defaultInstance = _StorageClass()
1882-
#endif
18831875

18841876
private init() {}
18851877

@@ -2059,15 +2051,11 @@ extension Grpc_Testing_ScenarioResultSummary: SwiftProtobuf.Message, SwiftProtob
20592051
var _startTime: SwiftProtobuf.Google_Protobuf_Timestamp? = nil
20602052
var _endTime: SwiftProtobuf.Google_Protobuf_Timestamp? = nil
20612053

2062-
#if swift(>=5.10)
20632054
// This property is used as the initial default value for new instances of the type.
20642055
// The type itself is protecting the reference to its storage via CoW semantics.
20652056
// This will force a copy to be made of this reference when the first mutation occurs;
20662057
// hence, it is safe to mark this as `nonisolated(unsafe)`.
20672058
static nonisolated(unsafe) let defaultInstance = _StorageClass()
2068-
#else
2069-
static let defaultInstance = _StorageClass()
2070-
#endif
20712059

20722060
private init() {}
20732061

Package.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ let products: [Product] = [
3434

3535
let dependencies: [Package.Dependency] = [
3636
.package(
37-
url: "https://github.com/grpc/grpc-swift.git",
38-
from: "2.2.1"
37+
url: "https://github.com/grpc/grpc-swift-2.git",
38+
from: "2.0.0"
3939
),
4040
.package(
4141
url: "https://github.com/apple/swift-nio.git",
@@ -69,12 +69,12 @@ let dependencies: [Package.Dependency] = [
6969

7070
// -------------------------------------------------------------------------------------------------
7171

72-
// This adds some build settings which allow us to map "@available(gRPCSwiftNIOTransport 1.x, *)" to
72+
// This adds some build settings which allow us to map "@available(gRPCSwiftNIOTransport 2.x, *)" to
7373
// the appropriate OS platforms.
74-
let nextMinorVersion = 3
74+
let nextMinorVersion = 0
7575
let availabilitySettings: [SwiftSetting] = (0 ... nextMinorVersion).map { minor in
7676
let name = "gRPCSwiftNIOTransport"
77-
let version = "1.\(minor)"
77+
let version = "2.\(minor)"
7878
let platforms = "macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0"
7979
let setting = "AvailabilityMacro=\(name) \(version):\(platforms)"
8080
return .enableExperimentalFeature(setting)
@@ -104,7 +104,7 @@ let targets: [Target] = [
104104
.target(
105105
name: "GRPCNIOTransportCore",
106106
dependencies: [
107-
.product(name: "GRPCCore", package: "grpc-swift"),
107+
.product(name: "GRPCCore", package: "grpc-swift-2"),
108108
.product(name: "NIOCore", package: "swift-nio"),
109109
.product(name: "NIOHTTP2", package: "swift-nio-http2"),
110110
.product(name: "NIOExtras", package: "swift-nio-extras"),
@@ -128,7 +128,7 @@ let targets: [Target] = [
128128
name: "GRPCNIOTransportHTTP2Posix",
129129
dependencies: [
130130
.target(name: "GRPCNIOTransportCore"),
131-
.product(name: "GRPCCore", package: "grpc-swift"),
131+
.product(name: "GRPCCore", package: "grpc-swift-2"),
132132
.product(name: "NIOPosix", package: "swift-nio"),
133133
.product(name: "NIOSSL", package: "swift-nio-ssl"),
134134
.product(name: "X509", package: "swift-certificates"),
@@ -143,7 +143,7 @@ let targets: [Target] = [
143143
name: "GRPCNIOTransportHTTP2TransportServices",
144144
dependencies: [
145145
.target(name: "GRPCNIOTransportCore"),
146-
.product(name: "GRPCCore", package: "grpc-swift"),
146+
.product(name: "GRPCCore", package: "grpc-swift-2"),
147147
.product(name: "NIOTransportServices", package: "swift-nio-transport-services"),
148148
],
149149
swiftSettings: defaultSwiftSettings
@@ -162,7 +162,7 @@ let targets: [Target] = [
162162
name: "GRPCNIOTransportHTTP2Tests",
163163
dependencies: [
164164
.target(name: "GRPCNIOTransportHTTP2"),
165-
.product(name: "GRPCCore", package: "grpc-swift"),
165+
.product(name: "GRPCCore", package: "grpc-swift-2"),
166166
.product(name: "X509", package: "swift-certificates"),
167167
.product(name: "NIOSSL", package: "swift-nio-ssl"),
168168
],

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ implementations for [gRPC Swift][gh-grpc-swift] built on top of
88
- 🎓 **Tutorials** are available in the documentation for `grpc/grpc-swift` on
99
the [Swift Package Index][spi-grpc-swift].
1010
- 💻 **Examples** are available in the `Examples` directory of the
11-
[`grpc/grpc-swift`](https://github.com/grpc/grpc-swift) repository
11+
[`grpc/grpc-swift`](https://github.com/grpc/grpc-swift-2) repository
1212
- 🚀 **Contributions** are welcome, please see [CONTRIBUTING.md](CONTRIBUTING.md)
1313
- 🪪 **License** is Apache 2.0, repeated in [LICENSE](License)
1414
- 🔒 **Security** issues should be reported via the process in [SECURITY.md](SECURITY.md)
1515

1616
[gh-swift-nio]: https://github.com/apple/swift-nio
17-
[gh-grpc-swift]: https://github.com/grpc/grpc-swift
17+
[gh-grpc-swift]: https://github.com/grpc/grpc-swift-2
1818
[spi-grpc-swift-nio-transport]: https://swiftpackageindex.com/grpc/grpc-swift-nio-transport/documentation

Sources/GRPCNIOTransportCore/Client/Connection/Connection.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private import Synchronization
4343
/// }
4444
/// }
4545
/// ```
46-
@available(gRPCSwiftNIOTransport 1.0, *)
46+
@available(gRPCSwiftNIOTransport 2.0, *)
4747
package final class Connection: Sendable {
4848
/// Events which can happen over the lifetime of the connection.
4949
package enum Event: Sendable {
@@ -406,7 +406,7 @@ package final class Connection: Sendable {
406406
}
407407
}
408408

409-
@available(gRPCSwiftNIOTransport 1.0, *)
409+
@available(gRPCSwiftNIOTransport 2.0, *)
410410
extension Connection {
411411
package struct Stream {
412412
package typealias Inbound = NIOAsyncChannelInboundStream<RPCResponsePart<GRPCNIOTransportBytes>>
@@ -480,7 +480,7 @@ extension Connection {
480480
}
481481
}
482482

483-
@available(gRPCSwiftNIOTransport 1.0, *)
483+
@available(gRPCSwiftNIOTransport 2.0, *)
484484
extension Connection {
485485
private enum State: Sendable {
486486
/// The connection is idle or connecting.

Sources/GRPCNIOTransportCore/Client/Connection/ConnectionBackoff.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
@available(gRPCSwiftNIOTransport 1.0, *)
17+
@available(gRPCSwiftNIOTransport 2.0, *)
1818
package struct ConnectionBackoff {
1919
package var initial: Duration
2020
package var max: Duration

Sources/GRPCNIOTransportCore/Client/Connection/ConnectionFactory.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package import NIOCore
1818
package import NIOHTTP2
1919
internal import NIOPosix
2020

21-
@available(gRPCSwiftNIOTransport 1.0, *)
21+
@available(gRPCSwiftNIOTransport 2.0, *)
2222
package protocol HTTP2Connector: Sendable {
2323
/// Attempt to establish a connection to the given address.
2424
///
@@ -31,7 +31,7 @@ package protocol HTTP2Connector: Sendable {
3131
) async throws -> HTTP2Connection
3232
}
3333

34-
@available(gRPCSwiftNIOTransport 1.0, *)
34+
@available(gRPCSwiftNIOTransport 2.0, *)
3535
package struct HTTP2Connection: Sendable {
3636
/// The underlying TCP connection wrapped up for use with gRPC.
3737
var channel: NIOAsyncChannel<ClientConnectionEvent, Void>

Sources/GRPCNIOTransportCore/Client/Connection/ConnectivityState.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package import GRPCCore
1818

19-
@available(gRPCSwiftNIOTransport 1.0, *)
19+
@available(gRPCSwiftNIOTransport 2.0, *)
2020
package enum ConnectivityState: Sendable, Hashable {
2121
/// This channel isn't trying to create a connection because of a lack of new or pending RPCs.
2222
///

Sources/GRPCNIOTransportCore/Client/Connection/GRPCChannel.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ private import DequeModule
1818
package import GRPCCore
1919
private import Synchronization
2020

21-
@available(gRPCSwiftNIOTransport 1.0, *)
21+
@available(gRPCSwiftNIOTransport 2.0, *)
2222
package final class GRPCChannel: ClientTransport {
2323
package typealias Bytes = GRPCNIOTransportBytes
2424

@@ -240,7 +240,7 @@ package final class GRPCChannel: ClientTransport {
240240
}
241241
}
242242

243-
@available(gRPCSwiftNIOTransport 1.0, *)
243+
@available(gRPCSwiftNIOTransport 2.0, *)
244244
extension GRPCChannel {
245245
package struct Config: Sendable {
246246
/// Configuration for HTTP/2 connections.
@@ -269,7 +269,7 @@ extension GRPCChannel {
269269
}
270270
}
271271

272-
@available(gRPCSwiftNIOTransport 1.0, *)
272+
@available(gRPCSwiftNIOTransport 2.0, *)
273273
extension GRPCChannel {
274274
enum MakeStreamResult {
275275
/// A stream was created, use it.
@@ -368,7 +368,7 @@ extension GRPCChannel {
368368
}
369369
}
370370

371-
@available(gRPCSwiftNIOTransport 1.0, *)
371+
@available(gRPCSwiftNIOTransport 2.0, *)
372372
extension GRPCChannel {
373373
private func handleClose(in group: inout DiscardingTaskGroup) {
374374
switch self.state.withLock({ $0.close() }) {
@@ -597,7 +597,7 @@ extension GRPCChannel {
597597
}
598598
}
599599

600-
@available(gRPCSwiftNIOTransport 1.0, *)
600+
@available(gRPCSwiftNIOTransport 2.0, *)
601601
extension GRPCChannel {
602602
struct StateMachine {
603603
enum State {
@@ -672,7 +672,7 @@ extension GRPCChannel {
672672
}
673673
}
674674

675-
@available(gRPCSwiftNIOTransport 1.0, *)
675+
@available(gRPCSwiftNIOTransport 2.0, *)
676676
extension GRPCChannel.StateMachine {
677677
mutating func start() {
678678
precondition(!self.running, "channel must only be started once")

Sources/GRPCNIOTransportCore/Client/Connection/LoadBalancers/LoadBalancer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17-
@available(gRPCSwiftNIOTransport 1.0, *)
17+
@available(gRPCSwiftNIOTransport 2.0, *)
1818
package enum LoadBalancer: Sendable {
1919
case roundRobin(RoundRobinLoadBalancer)
2020
case pickFirst(PickFirstLoadBalancer)
2121
}
2222

23-
@available(gRPCSwiftNIOTransport 1.0, *)
23+
@available(gRPCSwiftNIOTransport 2.0, *)
2424
extension LoadBalancer {
2525
package init(_ loadBalancer: RoundRobinLoadBalancer) {
2626
self = .roundRobin(loadBalancer)

Sources/GRPCNIOTransportCore/Client/Connection/LoadBalancers/LoadBalancerEvent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
/// Events emitted by load-balancers.
18-
@available(gRPCSwiftNIOTransport 1.0, *)
18+
@available(gRPCSwiftNIOTransport 2.0, *)
1919
package enum LoadBalancerEvent: Sendable, Hashable {
2020
/// The connectivity state of the subchannel changed.
2121
case connectivityStateChanged(ConnectivityState)

Sources/GRPCNIOTransportCore/Client/Connection/LoadBalancers/PickFirstLoadBalancer.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private import Synchronization
5656
/// }
5757
/// }
5858
/// ```
59-
@available(gRPCSwiftNIOTransport 1.0, *)
59+
@available(gRPCSwiftNIOTransport 2.0, *)
6060
package final class PickFirstLoadBalancer: Sendable {
6161
enum Input: Sendable, Hashable {
6262
/// Update the addresses used by the load balancer to the following endpoints.
@@ -171,7 +171,7 @@ package final class PickFirstLoadBalancer: Sendable {
171171
}
172172
}
173173

174-
@available(gRPCSwiftNIOTransport 1.0, *)
174+
@available(gRPCSwiftNIOTransport 2.0, *)
175175
extension PickFirstLoadBalancer {
176176
private func handleUpdateEndpoint(_ endpoint: Endpoint, in group: inout DiscardingTaskGroup) {
177177
if endpoint.addresses.isEmpty { return }
@@ -273,7 +273,7 @@ extension PickFirstLoadBalancer {
273273
}
274274
}
275275

276-
@available(gRPCSwiftNIOTransport 1.0, *)
276+
@available(gRPCSwiftNIOTransport 2.0, *)
277277
extension PickFirstLoadBalancer {
278278
enum State: Sendable {
279279
case active(Active)
@@ -286,7 +286,7 @@ extension PickFirstLoadBalancer {
286286
}
287287
}
288288

289-
@available(gRPCSwiftNIOTransport 1.0, *)
289+
@available(gRPCSwiftNIOTransport 2.0, *)
290290
extension PickFirstLoadBalancer.State {
291291
struct Active: Sendable {
292292
var endpoint: Endpoint?
@@ -315,7 +315,7 @@ extension PickFirstLoadBalancer.State {
315315
}
316316
}
317317

318-
@available(gRPCSwiftNIOTransport 1.0, *)
318+
@available(gRPCSwiftNIOTransport 2.0, *)
319319
extension PickFirstLoadBalancer.State.Active {
320320
mutating func updateEndpoint(
321321
_ endpoint: Endpoint,
@@ -485,7 +485,7 @@ extension PickFirstLoadBalancer.State.Active {
485485
}
486486
}
487487

488-
@available(gRPCSwiftNIOTransport 1.0, *)
488+
@available(gRPCSwiftNIOTransport 2.0, *)
489489
extension PickFirstLoadBalancer.State.Closing {
490490
mutating func updateSubchannelConnectivityState(
491491
_ connectivityState: ConnectivityState,
@@ -526,7 +526,7 @@ extension PickFirstLoadBalancer.State.Closing {
526526
}
527527
}
528528

529-
@available(gRPCSwiftNIOTransport 1.0, *)
529+
@available(gRPCSwiftNIOTransport 2.0, *)
530530
extension PickFirstLoadBalancer.State {
531531
enum OnUpdateEndpoint {
532532
case connect(Subchannel, close: Subchannel?)

Sources/GRPCNIOTransportCore/Client/Connection/LoadBalancers/RoundRobinLoadBalancer.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private import NIOConcurrencyHelpers
5858
/// }
5959
/// }
6060
/// ```
61-
@available(gRPCSwiftNIOTransport 1.0, *)
61+
@available(gRPCSwiftNIOTransport 2.0, *)
6262
package final class RoundRobinLoadBalancer: Sendable {
6363
enum Input: Sendable, Hashable {
6464
/// Update the addresses used by the load balancer to the following endpoints.
@@ -204,7 +204,7 @@ package final class RoundRobinLoadBalancer: Sendable {
204204
}
205205
}
206206

207-
@available(gRPCSwiftNIOTransport 1.0, *)
207+
@available(gRPCSwiftNIOTransport 2.0, *)
208208
extension RoundRobinLoadBalancer {
209209
/// Handles an update in endpoints.
210210
///
@@ -347,7 +347,7 @@ extension RoundRobinLoadBalancer {
347347
}
348348
}
349349

350-
@available(gRPCSwiftNIOTransport 1.0, *)
350+
@available(gRPCSwiftNIOTransport 2.0, *)
351351
extension RoundRobinLoadBalancer {
352352
private enum State {
353353
case active(Active)
@@ -741,7 +741,7 @@ extension RoundRobinLoadBalancer {
741741
}
742742
}
743743

744-
@available(gRPCSwiftNIOTransport 1.0, *)
744+
@available(gRPCSwiftNIOTransport 2.0, *)
745745
extension ConnectivityState {
746746
static func aggregate(_ states: some Collection<ConnectivityState>) -> ConnectivityState {
747747
// See https://github.com/grpc/grpc/blob/7f664c69b2a636386fbf95c16bc78c559734ce0f/doc/load-balancing.md

0 commit comments

Comments
 (0)